Compare commits
1 Commits
bfcdd1b2e5
...
0327d22d7f
Author | SHA1 | Date | |
---|---|---|---|
0327d22d7f |
|
@ -156,8 +156,6 @@ class RepositoryConfig:
|
||||||
owner: str
|
owner: str
|
||||||
repo: str
|
repo: str
|
||||||
base_branch: str
|
base_branch: str
|
||||||
assignee: str | None = None
|
|
||||||
reviewer: str | None = None
|
|
||||||
|
|
||||||
def repo_url(self) -> str:
|
def repo_url(self) -> str:
|
||||||
return f'{self.gitea_url}:{self.owner}/{self.repo}.git'.replace(
|
return f'{self.gitea_url}:{self.owner}/{self.repo}.git'.replace(
|
||||||
|
@ -508,18 +506,8 @@ def push_changes(
|
||||||
head=branch_name,
|
head=branch_name,
|
||||||
base=repository_config.base_branch,
|
base=repository_config.base_branch,
|
||||||
labels=['aider'],
|
labels=['aider'],
|
||||||
assignee=repository_config.assignee,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add reviewer if specified (requires separate API call after PR creation)
|
|
||||||
if repository_config.reviewer and pr_response.get('number'):
|
|
||||||
gitea_client.add_pull_request_reviewer(
|
|
||||||
owner=repository_config.owner,
|
|
||||||
repo=repository_config.repo,
|
|
||||||
pr_number=int(pr_response.get('number')),
|
|
||||||
reviewer=repository_config.reviewer,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Extract PR number and URL if available
|
# Extract PR number and URL if available
|
||||||
return IssueResolution(
|
return IssueResolution(
|
||||||
True,
|
True,
|
||||||
|
|
|
@ -55,14 +55,6 @@ def parse_args():
|
||||||
help='Model to use for evaluating code (overrides default)',
|
help='Model to use for evaluating code (overrides default)',
|
||||||
default=None,
|
default=None,
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
|
||||||
'--assignee',
|
|
||||||
help='Username to automatically assign as assignee for created pull requests',
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
'--reviewer',
|
|
||||||
help='Username to automatically assign as reviewer for created pull requests',
|
|
||||||
)
|
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,8 +84,6 @@ def main():
|
||||||
owner=args.owner,
|
owner=args.owner,
|
||||||
repo=repo,
|
repo=repo,
|
||||||
base_branch=args.base_branch,
|
base_branch=args.base_branch,
|
||||||
assignee=args.assignee,
|
|
||||||
reviewer=args.reviewer,
|
|
||||||
)
|
)
|
||||||
solve_issues_in_repository(repository_config, client, seen_issues_db)
|
solve_issues_in_repository(repository_config, client, seen_issues_db)
|
||||||
del repo
|
del repo
|
||||||
|
|
|
@ -139,7 +139,6 @@ class GiteaClient:
|
||||||
head: str,
|
head: str,
|
||||||
base: str,
|
base: str,
|
||||||
labels: list[str] = None,
|
labels: list[str] = None,
|
||||||
assignee: str = None,
|
|
||||||
) -> dict:
|
) -> dict:
|
||||||
"""Create a pull request and optionally apply labels.
|
"""Create a pull request and optionally apply labels.
|
||||||
|
|
||||||
|
@ -151,7 +150,6 @@ class GiteaClient:
|
||||||
head (str): The name of the branch where changes are implemented.
|
head (str): The name of the branch where changes are implemented.
|
||||||
base (str): The name of the branch you want the changes pulled into.
|
base (str): The name of the branch you want the changes pulled into.
|
||||||
labels (list[str], optional): List of label names to apply to the pull request.
|
labels (list[str], optional): List of label names to apply to the pull request.
|
||||||
assignee (str, optional): Username to assign as assignee for the pull request.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict: The created pull request data.
|
dict: The created pull request data.
|
||||||
|
@ -167,9 +165,6 @@ class GiteaClient:
|
||||||
'base': base,
|
'base': base,
|
||||||
}
|
}
|
||||||
|
|
||||||
if assignee:
|
|
||||||
json_data['assignee'] = assignee
|
|
||||||
|
|
||||||
response = self.session.post(url, json=json_data)
|
response = self.session.post(url, json=json_data)
|
||||||
# If a pull request for this head/base already exists, return it instead of crashing
|
# If a pull request for this head/base already exists, return it instead of crashing
|
||||||
if response.status_code == 409:
|
if response.status_code == 409:
|
||||||
|
@ -190,36 +185,6 @@ class GiteaClient:
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
def add_pull_request_reviewer(
|
|
||||||
self,
|
|
||||||
owner: str,
|
|
||||||
repo: str,
|
|
||||||
pr_number: int,
|
|
||||||
reviewer: str,
|
|
||||||
) -> bool:
|
|
||||||
"""Add a reviewer to an existing pull request.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
owner (str): Owner of the repository.
|
|
||||||
repo (str): Name of the repository.
|
|
||||||
pr_number (int): Number of the pull request.
|
|
||||||
reviewer (str): Username to assign as reviewer.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
bool: True if the reviewer was added successfully, False otherwise.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
requests.HTTPError: If the API request fails.
|
|
||||||
"""
|
|
||||||
url = f'{self.gitea_url}/repos/{owner}/{repo}/pulls/{pr_number}/requested_reviewers'
|
|
||||||
json_data = {'reviewers': [reviewer]}
|
|
||||||
response = self.session.post(url, json=json_data)
|
|
||||||
if response.status_code == 422:
|
|
||||||
logger.warning('Failed to add reviewer %s to PR #%s', reviewer, pr_number)
|
|
||||||
return False
|
|
||||||
response.raise_for_status()
|
|
||||||
return True
|
|
||||||
|
|
||||||
def get_failed_pipelines(self, owner: str, repo: str, pr_number: str) -> list[int]:
|
def get_failed_pipelines(self, owner: str, repo: str, pr_number: str) -> list[int]:
|
||||||
"""Fetch pipeline runs for a PR and return IDs of failed runs."""
|
"""Fetch pipeline runs for a PR and return IDs of failed runs."""
|
||||||
url = f'{self.gitea_url}/repos/{owner}/{repo}/actions/runs'
|
url = f'{self.gitea_url}/repos/{owner}/{repo}/actions/runs'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user