Skip to content

Merge push-nqrvnzxzrpkz Into main#92

Open
dclong wants to merge 1 commit into
mainfrom
push-nqrvnzxzrpkz
Open

Merge push-nqrvnzxzrpkz Into main#92
dclong wants to merge 1 commit into
mainfrom
push-nqrvnzxzrpkz

Conversation

@dclong

@dclong dclong commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread github_rest_api/pr_content.py
Comment thread github_rest_api/pr_content.py Outdated
Comment thread github_rest_api/scripts/github/create_pull_request.py
Comment on lines +133 to 147
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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

Comment thread tests/test_pr_content.py
Comment on lines +215 to +222
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")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since we are removing the _pull_request_exists helper function in favor of an early exit in main, we should remove this unused test to keep the test suite clean and passing.

@dclong dclong force-pushed the push-nqrvnzxzrpkz branch from 354d521 to 8f663e6 Compare June 22, 2026 15:35
@dclong dclong force-pushed the push-nqrvnzxzrpkz branch from 8f663e6 to e4c9fb8 Compare June 23, 2026 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant