-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable GitAuto to react to PR review comments, letting users make pre…
…cise adjustments without rerunning from the issue, dodging randomness.
- Loading branch information
1 parent
16542e1
commit d745fe6
Showing
11 changed files
with
1,507 additions
and
40 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import requests | ||
from config import GITHUB_API_URL, TIMEOUT | ||
from services.github.create_headers import create_headers | ||
from services.github.github_types import BaseArgs | ||
from services.github.user_manager import check_user_is_collaborator | ||
from utils.handle_exceptions import handle_exceptions | ||
|
||
|
||
@handle_exceptions(default_return_value=None, raise_on_error=False) | ||
def add_reviewers(base_args: BaseArgs): | ||
"""https://docs.github.com/en/rest/pulls/review-requests?apiVersion=2022-11-28#request-reviewers-for-a-pull-request""" | ||
owner, repo, pr_number, token, reviewers = ( | ||
base_args["owner"], | ||
base_args["repo"], | ||
base_args["pr_number"], | ||
base_args["token"], | ||
base_args["reviewers"], | ||
) | ||
|
||
# Check if the reviewers are collaborators because reviewers must be collaborators | ||
valid_reviewers: list[str] = [] | ||
for reviewer in reviewers: | ||
is_collaborator = check_user_is_collaborator( | ||
owner=owner, repo=repo, user=reviewer, token=token | ||
) | ||
if is_collaborator: | ||
valid_reviewers.append(reviewer) | ||
|
||
# If no valid reviewers, return | ||
if not valid_reviewers: | ||
return | ||
|
||
# Add the reviewers to the pull request | ||
url = f"{GITHUB_API_URL}/repos/{owner}/{repo}/pulls/{pr_number}/requested_reviewers" | ||
headers = create_headers(token=token) | ||
json = {"reviewers": valid_reviewers} | ||
response = requests.post(url=url, headers=headers, json=json, timeout=TIMEOUT) | ||
response.raise_for_status() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
RESOLVE_FEEDBACK = """ | ||
You are an top-class software engineer. | ||
Given information such as a pull request title, body, changes, workflow file content, and check run error log, resolve the feedback and write a plan to fix the error in a language that is used in the input (e.g. the plan should be in English but if the input is mainly in Japanese for example, the plan should be in Japanese). | ||
Output format would be like this: | ||
## What the feedback is | ||
## Where to change | ||
## How to change | ||
Each section should be concise and to the point. Should not be long. | ||
""" |
Oops, something went wrong.