refactor: defer PR comment handling until all issues are resolved and batch process them
This commit is contained in:
parent
1f64cdb32e
commit
44b7d148f7
|
@ -495,6 +495,9 @@ def solve_issues_in_repository(
|
||||||
logger.info('No issues found for %s', repository_config.repo)
|
logger.info('No issues found for %s', repository_config.repo)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# batch up PRs to handle comments after all issues are resolved
|
||||||
|
jobs: list[tuple[str, str, str]] = []
|
||||||
|
|
||||||
for issue in issues:
|
for issue in issues:
|
||||||
issue_url = issue.get('web_url')
|
issue_url = issue.get('web_url')
|
||||||
issue_number = issue.get('number')
|
issue_number = issue.get('number')
|
||||||
|
@ -516,15 +519,8 @@ def solve_issues_in_repository(
|
||||||
client,
|
client,
|
||||||
)
|
)
|
||||||
if issue_resolution.success:
|
if issue_resolution.success:
|
||||||
handle_pr_comments(
|
# defer comment handling until after all issues complete
|
||||||
repository_config,
|
jobs.append((issue_url, issue_resolution.pull_request_id, branch_name))
|
||||||
issue_resolution.pull_request_id,
|
|
||||||
branch_name,
|
|
||||||
Path(repository_path),
|
|
||||||
client,
|
|
||||||
seen_issues_db,
|
|
||||||
issue_url,
|
|
||||||
)
|
|
||||||
seen_issues_db.mark_as_seen(issue_url, str(issue_number))
|
seen_issues_db.mark_as_seen(issue_url, str(issue_number))
|
||||||
seen_issues_db.update_pr_info(
|
seen_issues_db.update_pr_info(
|
||||||
issue_url,
|
issue_url,
|
||||||
|
@ -538,6 +534,21 @@ def solve_issues_in_repository(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# once all new issues are done, process any PR comments in batch
|
||||||
|
for issue_url, pr_id, branch_name in jobs:
|
||||||
|
with tempfile.TemporaryDirectory() as repository_path:
|
||||||
|
run_cmd(['git', 'clone', repository_config.repo_url(), repository_path])
|
||||||
|
run_cmd(['git', 'checkout', branch_name], repository_path)
|
||||||
|
handle_pr_comments(
|
||||||
|
repository_config,
|
||||||
|
pr_id,
|
||||||
|
branch_name,
|
||||||
|
Path(repository_path),
|
||||||
|
client,
|
||||||
|
seen_issues_db,
|
||||||
|
issue_url,
|
||||||
|
)
|
||||||
|
|
||||||
def handle_pr_comments(
|
def handle_pr_comments(
|
||||||
repository_config,
|
repository_config,
|
||||||
pr_number,
|
pr_number,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user