Skip to content

feat(internal/gapicgen): fix genbot PR descriptions#13189

Merged
quartzmo merged 3 commits intogoogleapis:mainfrom
quartzmo:genbot-fix-pr-description
Oct 20, 2025
Merged

feat(internal/gapicgen): fix genbot PR descriptions#13189
quartzmo merged 3 commits intogoogleapis:mainfrom
quartzmo:genbot-fix-pr-description

Conversation

@quartzmo
Copy link
Copy Markdown
Member

When a go-genproto regeneration is triggered after a long period of inactivity, genbot would attempt to include all intervening commits in the pull request description. This could result a PR description being rejected by GitHub.

genbot now identifies only the commits that are relevant to the go-genproto regeneration by checking which commits affected the watched proto files.

The new PR description now includes:

  • A list of only the relevant commits.
  • A list of the specific packages affected by each commit.

fixes: #13188

When a `go-genproto` regeneration is triggered after a long period
of inactivity, genbot would attempt to include all intervening
commits in the pull request description. This could
result a PR description being rejected by GitHub..

genbot now identifies only the commits that are relevant to the
go-genproto regeneration by checking which commits affected the
watched proto files.

The new PR description now includes:
- A list of only the relevant commits.
- A list of the specific packages affected by each commit.

fixes: googleapis#13188
@quartzmo quartzmo requested a review from a team October 20, 2025 21:47
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @quartzmo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a long-standing issue where genbot would generate excessively verbose pull request descriptions for go-genproto regenerations, often leading to GitHub rejecting them due to length constraints. The core change introduces a more sophisticated commit filtering mechanism, ensuring that only commits directly impacting watched proto files are included in the PR description. Furthermore, the updated descriptions will now clearly enumerate the specific Go packages affected by each relevant commit, providing reviewers with a more focused and actionable summary of the changes.

Highlights

  • Improved PR Description Generation: genbot now intelligently filters commits for go-genproto regenerations, including only those that affect watched proto files, to prevent overly long PR descriptions that GitHub might reject.
  • Detailed Commit Information: The generated PR descriptions will now list only relevant commits and specify the Go packages impacted by each of those commits, providing more focused context.
  • Code Refactoring for Git Operations: The internal git package has been updated, including an exported function FilesChanged for retrieving files modified in a commit, and the ChangeInfo struct has been extended to store affected packages.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

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

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 addresses an issue with overly large PR descriptions for go-genproto regenerations by intelligently filtering for relevant commits. The approach of checking which commits affect watched proto files is sound. The changes also enhance the PR description by listing the specific packages affected by each commit. The implementation is mostly solid, but I've provided one suggestion in internal/gapicgen/generator/generator.go to refactor the new logic. This refactoring improves efficiency by using a map for lookups, prevents potential duplicate package listings, and ensures a deterministic order for the affected packages, which improves the overall robustness and quality of the generated PR descriptions.

Comment thread internal/gapicgen/generator/generator.go Outdated
bhshkh
bhshkh previously approved these changes Oct 20, 2025
shollyman
shollyman previously approved these changes Oct 20, 2025
Copy link
Copy Markdown
Contributor

@shollyman shollyman left a comment

Choose a reason for hiding this comment

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

I have silly questions about the new filtration, but LGTMing because I assume the error is in my understanding.

return nil, err
}
changes, err := git.ParseChangeInfo(googleapisDir, commits)
affectedProtos := make(map[string][]string)
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.

My question out the gate is whether we care about other artifacts like service config yaml files. e.g. if a service changes its retry policy, do we need to propagate that?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Here's the list of what's in scope for genbot currently. Its scope has been much reduced since the days when go-genproto contained all the GAPIC protos. I don't think there are any GAPIC-related files like service config yamls to worry about anymore: https://github.com/googleapis/google-cloud-go/blob/main/internal/gapicgen/generator/genproto.go#L56

Comment thread internal/gapicgen/git/git.go Outdated
}

// filesChanged returns a list of files changed in a commit for the provdied
// FilesChanged returns a list of files changed in a commit for the provdied
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.

nit: since you're already touching the line, maybe fix up the s/provdied/provided/ typo

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed!

@quartzmo quartzmo dismissed stale reviews from shollyman and bhshkh via 25ae052 October 20, 2025 22:14
@quartzmo quartzmo enabled auto-merge (squash) October 20, 2025 22:19
@quartzmo quartzmo merged commit 4209188 into googleapis:main Oct 20, 2025
9 checks passed
@quartzmo quartzmo deleted the genbot-fix-pr-description branch October 20, 2025 22:21
quartzmo added a commit to quartzmo/google-cloud-go that referenced this pull request Oct 21, 2025
quartzmo added a commit to quartzmo/google-cloud-go that referenced this pull request Oct 21, 2025
The genbot would previously crash if it encountered a commit that
deleted a proto file. This was because it was trying to read the
file from the current filesystem, where it no longer existed.

This change updates the genbot to read the file content from the
historical commit directly, making the process resilient to file
deletions and renames.i

refs: googleapis#13188
refs: googleapis#13189
quartzmo added a commit that referenced this pull request Oct 21, 2025
The genbot would previously crash if it encountered a commit that
deleted a proto file. This was because it was trying to read the file
from the current filesystem, where it no longer existed.

This change updates the genbot to read the file content from the
historical commit directly, making the process resilient to file
deletions and renames.i

refs: #13188
refs: #13189

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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.

genbot build broken by too many commits in generated PR description

3 participants