Skip to content

chore: add a script to easily checkout prs#3600

Open
rickeylev wants to merge 2 commits intobazel-contrib:mainfrom
rickeylev:chore.gitpr.tool
Open

chore: add a script to easily checkout prs#3600
rickeylev wants to merge 2 commits intobazel-contrib:mainfrom
rickeylev:chore.gitpr.tool

Conversation

@rickeylev
Copy link
Collaborator

This adds a script I've had for awhile to make it easier to grab PRs and work on them.

It makes grabbing and editing a user's PR much easier, especially with some aliases
setup:

git pr-checkout <PR url>
...edit files...
git pr-push

While things like gh pr checkout exist, it doesn't well handle the "triangle"
workflow and some other edge cases.

@rickeylev rickeylev requested a review from aignas as a code owner February 15, 2026 08:55
@rickeylev rickeylev enabled auto-merge February 15, 2026 08:55
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @rickeylev, 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 introduces a new utility script designed to significantly simplify the workflow for interacting with GitHub Pull Requests. It addresses common complexities, particularly in 'triangle' development models, by automating the process of checking out, pulling updates from, and pushing changes to PR branches. The script aims to enhance developer efficiency by providing a more intuitive command-line interface for PR management.

Highlights

  • New git-pr script added: A new shell script, tools/git-pr, has been introduced to streamline common Git operations related to Pull Requests.
  • Simplified PR Checkout: The git-pr checkout command allows users to easily fetch and switch to a PR's branch using its number or URL, handling remote setup automatically.
  • Enhanced Push/Pull for PRs: The script includes git-pr pull and git-pr push commands that correctly interact with the PR's remote branch, simplifying the 'triangle' workflow.
  • Dependency Checks: The checkout command now checks for the presence of gh (GitHub CLI) and jq and provides informative error messages if they are missing.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • tools/git-pr
    • Added a new executable shell script to manage GitHub Pull Request workflows.
Activity
  • No activity has been recorded on this pull request yet.
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
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 introduces a useful git-pr script to streamline the process of checking out, pulling, and pushing changes for GitHub pull requests, especially in a 'triangle workflow' setup. However, the script contains several instances of unquoted variables in shell commands, specifically in git push and git pull operations, which can lead to word splitting and argument injection. This practice is insecure and should be remediated by consistently using double quotes around variables. Additionally, there is a critical bug in handling the base remote for certain PRs, and improvements are needed for error handling consistency and user experience.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@aignas
Copy link
Collaborator

aignas commented Feb 15, 2026

I use the gh CLI and you just need to do gh pr checkout to checkout a particular PR.

@rickeylev
Copy link
Collaborator Author

I've had endless trouble trying to use plain gh pr checkout. Checkout out usually worked, but updating and pushing would frequently break. 🤷

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.

2 participants