Compare commits
1 Commits
a1d1f01606
...
0b9505f370
Author | SHA1 | Date | |
---|---|---|---|
0b9505f370 |
|
@ -156,7 +156,6 @@ class RepositoryConfig:
|
||||||
owner: str
|
owner: str
|
||||||
repo: str
|
repo: str
|
||||||
base_branch: str
|
base_branch: str
|
||||||
assignee: 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(
|
||||||
|
@ -498,10 +497,7 @@ def push_changes(
|
||||||
cmd = ['git', 'push', 'origin', branch_name, '--force']
|
cmd = ['git', 'push', 'origin', branch_name, '--force']
|
||||||
run_cmd(cmd, cwd)
|
run_cmd(cmd, cwd)
|
||||||
|
|
||||||
# Then create the PR with the aider label and optional assignee/reviewer
|
# Then create the PR with the aider label
|
||||||
assignees = [repository_config.assignee] if repository_config.assignee else None
|
|
||||||
reviewers = [repository_config.assignee] if repository_config.assignee else None
|
|
||||||
|
|
||||||
pr_response = gitea_client.create_pull_request(
|
pr_response = gitea_client.create_pull_request(
|
||||||
owner=repository_config.owner,
|
owner=repository_config.owner,
|
||||||
repo=repository_config.repo,
|
repo=repository_config.repo,
|
||||||
|
@ -510,8 +506,6 @@ def push_changes(
|
||||||
head=branch_name,
|
head=branch_name,
|
||||||
base=repository_config.base_branch,
|
base=repository_config.base_branch,
|
||||||
labels=['aider'],
|
labels=['aider'],
|
||||||
assignees=assignees,
|
|
||||||
reviewers=reviewers,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Extract PR number and URL if available
|
# Extract PR number and URL if available
|
||||||
|
|
|
@ -55,11 +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 and reviewer for created pull requests',
|
|
||||||
default=None,
|
|
||||||
)
|
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,7 +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,
|
|
||||||
)
|
)
|
||||||
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,10 +139,8 @@ class GiteaClient:
|
||||||
head: str,
|
head: str,
|
||||||
base: str,
|
base: str,
|
||||||
labels: list[str] = None,
|
labels: list[str] = None,
|
||||||
assignees: list[str] = None,
|
|
||||||
reviewers: list[str] = None,
|
|
||||||
) -> dict:
|
) -> dict:
|
||||||
"""Create a pull request and optionally apply labels, assignees, and reviewers.
|
"""Create a pull request and optionally apply labels.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
owner (str): Owner of the repository.
|
owner (str): Owner of the repository.
|
||||||
|
@ -152,8 +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.
|
||||||
assignees (list[str], optional): List of usernames to assign to the pull request.
|
|
||||||
reviewers (list[str], optional): List of usernames to request reviews from.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict: The created pull request data.
|
dict: The created pull request data.
|
||||||
|
@ -169,12 +165,6 @@ class GiteaClient:
|
||||||
'base': base,
|
'base': base,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add assignees and reviewers if provided
|
|
||||||
if assignees:
|
|
||||||
json_data['assignees'] = assignees
|
|
||||||
if reviewers:
|
|
||||||
json_data['reviewers'] = reviewers
|
|
||||||
|
|
||||||
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:
|
||||||
|
@ -189,100 +179,11 @@ class GiteaClient:
|
||||||
pr.get('head', {}).get('ref') == head
|
pr.get('head', {}).get('ref') == head
|
||||||
and pr.get('base', {}).get('ref') == base
|
and pr.get('base', {}).get('ref') == base
|
||||||
):
|
):
|
||||||
# Try to set assignees and reviewers on existing PR
|
|
||||||
pr_number = pr.get('number')
|
|
||||||
if assignees and pr_number:
|
|
||||||
self.set_pull_request_assignees(
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
pr_number,
|
|
||||||
assignees,
|
|
||||||
)
|
|
||||||
if reviewers and pr_number:
|
|
||||||
self.set_pull_request_reviewers(
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
pr_number,
|
|
||||||
reviewers,
|
|
||||||
)
|
|
||||||
return pr
|
return pr
|
||||||
# fallback to raise if we can’t find it
|
# fallback to raise if we can’t find it
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
return response.json()
|
||||||
pr_data = response.json()
|
|
||||||
|
|
||||||
# If initial creation didn't set assignees/reviewers, try setting them separately
|
|
||||||
pr_number = pr_data.get('number')
|
|
||||||
if pr_number:
|
|
||||||
if assignees:
|
|
||||||
self.set_pull_request_assignees(owner, repo, pr_number, assignees)
|
|
||||||
if reviewers:
|
|
||||||
self.set_pull_request_reviewers(owner, repo, pr_number, reviewers)
|
|
||||||
|
|
||||||
return pr_data
|
|
||||||
|
|
||||||
def set_pull_request_assignees(
|
|
||||||
self,
|
|
||||||
owner: str,
|
|
||||||
repo: str,
|
|
||||||
pr_number: int,
|
|
||||||
assignees: list[str],
|
|
||||||
) -> bool:
|
|
||||||
"""Set assignees for a pull request.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
owner (str): Owner of the repository.
|
|
||||||
repo (str): Name of the repository.
|
|
||||||
pr_number (int): Pull request number.
|
|
||||||
assignees (list[str]): List of usernames to assign.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
bool: True if successful, False otherwise.
|
|
||||||
"""
|
|
||||||
url = f'{self.gitea_url}/repos/{owner}/{repo}/pulls/{pr_number}/assignees'
|
|
||||||
json_data = {'assignees': assignees}
|
|
||||||
try:
|
|
||||||
response = self.session.put(url, json=json_data)
|
|
||||||
response.raise_for_status()
|
|
||||||
logger.info('Assigned users %s to PR #%s', assignees, pr_number)
|
|
||||||
return True
|
|
||||||
except Exception:
|
|
||||||
logger.warning('Failed to assign users %s to PR #%s', assignees, pr_number)
|
|
||||||
return False
|
|
||||||
|
|
||||||
def set_pull_request_reviewers(
|
|
||||||
self,
|
|
||||||
owner: str,
|
|
||||||
repo: str,
|
|
||||||
pr_number: int,
|
|
||||||
reviewers: list[str],
|
|
||||||
) -> bool:
|
|
||||||
"""Set reviewers for a pull request.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
owner (str): Owner of the repository.
|
|
||||||
repo (str): Name of the repository.
|
|
||||||
pr_number (int): Pull request number.
|
|
||||||
reviewers (list[str]): List of usernames to request reviews from.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
bool: True if successful, False otherwise.
|
|
||||||
"""
|
|
||||||
url = f'{self.gitea_url}/repos/{owner}/{repo}/pulls/{pr_number}/reviewers'
|
|
||||||
json_data = {'reviewers': reviewers}
|
|
||||||
try:
|
|
||||||
response = self.session.post(url, json=json_data)
|
|
||||||
response.raise_for_status()
|
|
||||||
logger.info('Requested reviews from %s for PR #%s', reviewers, pr_number)
|
|
||||||
return True
|
|
||||||
except Exception:
|
|
||||||
logger.warning(
|
|
||||||
'Failed to request reviews from %s for PR #%s',
|
|
||||||
reviewers,
|
|
||||||
pr_number,
|
|
||||||
)
|
|
||||||
return False
|
|
||||||
|
|
||||||
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."""
|
||||||
|
|
|
@ -69,10 +69,9 @@ class TestClaudeCodeIntegration:
|
||||||
'claude',
|
'claude',
|
||||||
'-p',
|
'-p',
|
||||||
'--output-format',
|
'--output-format',
|
||||||
'stream-json',
|
'json',
|
||||||
'--debug',
|
'--max-turns',
|
||||||
'--verbose',
|
'10',
|
||||||
'--dangerously-skip-permissions',
|
|
||||||
issue,
|
issue,
|
||||||
]
|
]
|
||||||
assert cmd == expected
|
assert cmd == expected
|
||||||
|
@ -85,10 +84,9 @@ class TestClaudeCodeIntegration:
|
||||||
'claude',
|
'claude',
|
||||||
'-p',
|
'-p',
|
||||||
'--output-format',
|
'--output-format',
|
||||||
'stream-json',
|
'json',
|
||||||
'--debug',
|
'--max-turns',
|
||||||
'--verbose',
|
'10',
|
||||||
'--dangerously-skip-permissions',
|
|
||||||
'--model',
|
'--model',
|
||||||
'claude-3-sonnet',
|
'claude-3-sonnet',
|
||||||
issue,
|
issue,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user