Merge push-nqrvnzxzrpkz Into main#92
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces automated generation of pull request titles and descriptions. It adds a compare method to the Repository class, a new pr_content module featuring both deterministic and LiteLLM-based AI generation layers, and CLI options to trigger this generation when creating a pull request. The review feedback suggests several key improvements: enhancing breaking change detection to support both 'BREAKING CHANGE' and 'BREAKING-CHANGE' formats, making the LLM JSON parsing more robust against markdown code block wrapping, and optimizing API calls in the CLI script by fetching open pull requests once and exiting early if the PR already exists.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| pull_request = { | ||
| "base": args.base_branch, | ||
| "head": args.head_branch, | ||
| "title": f"Merge {args.head_branch} Into {args.base_branch}", | ||
| } | ||
| # Generating content only makes sense for a PR that does not exist yet; | ||
| # create_pull_request returns the existing PR untouched otherwise. | ||
| if args.generate_description and not _pull_request_exists( | ||
| repo, args.head_branch, args.base_branch | ||
| ): | ||
| content = generate_content(repo, args.head_branch, args.base_branch, args.model) | ||
| if content is not None: | ||
| pull_request["title"], pull_request["body"] = content | ||
| repo.create_pull_request(pull_request) | ||
| return 0 |
There was a problem hiding this comment.
Instead of calling _pull_request_exists (which fetches all open PRs) and then calling repo.create_pull_request (which fetches all open PRs again), we can fetch the open PRs once in main. If the PR already exists, we can print a message and exit early with 0. This avoids redundant paginated API calls and saves time/rate limits.
# Check if the pull request already exists to avoid redundant description generation and API calls.
prs = repo.get_pull_requests()
existing_pr = next(
(
pr
for pr in prs
if pr["head"]["ref"] == args.head_branch
and pr["base"]["ref"] == args.base_branch
),
None,
)
if existing_pr is not None:
print(
f"Pull request already exists: {existing_pr.get('html_url')}",
file=sys.stderr,
)
return 0
pull_request = {
"base": args.base_branch,
"head": args.head_branch,
"title": f"Merge {args.head_branch} Into {args.base_branch}",
}
if args.generate_description:
content = generate_content(repo, args.head_branch, args.base_branch, args.model)
if content is not None:
pull_request["title"], pull_request["body"] = content
repo.create_pull_request(pull_request)
return 0| def test_pull_request_exists(): | ||
| repo = MagicMock() | ||
| repo.get_pull_requests.return_value = [ | ||
| {"head": {"ref": "dev"}, "base": {"ref": "main"}}, | ||
| ] | ||
| assert create_pull_request._pull_request_exists(repo, "dev", "main") | ||
| assert not create_pull_request._pull_request_exists(repo, "feature", "main") | ||
|
|
354d521 to
8f663e6
Compare
8f663e6 to
e4c9fb8
Compare
No description provided.