Skip to content

feat(gitstore): add support for specifying git branch (via GITSTORE_G…#2298

Merged
luispater merged 1 commit intorouter-for-me:devfrom
snoyiatk:feat/add-gitstore-branch
Apr 6, 2026
Merged

feat(gitstore): add support for specifying git branch (via GITSTORE_G…#2298
luispater merged 1 commit intorouter-for-me:devfrom
snoyiatk:feat/add-gitstore-branch

Conversation

@snoyiatk
Copy link
Copy Markdown

Implement git branch checkout per #2090

Add GITSTORE_GIT_BRANCH to specify which branch to checkout & push, allowing multiple configuration for single repo, instead of creating multiple repo for each instance.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 significantly enhances the gitstore component by introducing explicit support for specifying a Git branch. This allows the system to interact with different branches of a single remote repository, providing greater flexibility for managing various configurations or environments without requiring multiple repository instances.

Highlights

  • Git Branch Configuration: Introduced the GITSTORE_GIT_BRANCH environment variable, allowing users to specify a target Git branch for GitTokenStore operations.
  • Enhanced Repository Management: Enabled the use of a single Git repository for multiple configurations by supporting branch-specific checkouts, reducing the need for separate repositories.

🧠 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.

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.

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

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d32d5795f5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread cmd/server/main.go Outdated
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 adds support for specifying a git branch for the git-based token store. The changes correctly propagate the new gitStoreBranch configuration from environment variables to the gitstore component, and update the clone and pull operations to use the specified branch. However, I found an issue in the logic for handling empty remote repositories where the specified branch is not used, causing commits to go to the default branch. I've added a comment with a suggested fix.

Comment thread internal/store/gitstore.go
Copy link
Copy Markdown
Collaborator

@luispater luispater left a comment

Choose a reason for hiding this comment

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

Summary:
This PR adds support for selecting a git branch for gitstore via GITSTORE_GIT_BRANCH, wiring the value from cmd/server/main.go into GitTokenStore and using it in clone/pull.

Blocking findings:

  • Backward compatibility regression: the default branch is now hardcoded to main (gitStoreBranch := "main"), so when GITSTORE_GIT_BRANCH is not set, behavior no longer follows the remote default branch. Repos whose default branch is not main may fail on clone/pull with reference-not-found errors.

Non-blocking findings:

  • No tests were added for branch selection behavior (unset branch, valid custom branch, nonexistent branch).
  • Config/docs updates for GITSTORE_GIT_BRANCH are missing.

Suggested fix:

  • Keep default branch empty (or only apply branch override when env var is explicitly set and non-empty), so existing behavior remains unchanged unless users opt in.
  • Add targeted tests for clone/pull behavior with and without explicit branch configuration.

Test plan:

  • Unit/integration tests for EnsureRepository with:
    1. no branch configured (remote default branch),
    2. explicit branch configured,
    3. nonexistent branch configured (expected error path).

@snoyiatk
Copy link
Copy Markdown
Author

snoyiatk commented Apr 1, 2026

been busy for a while, will update the PR soon

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4746f146db

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread internal/store/gitstore.go
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6efd963c92

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread internal/store/gitstore.go Outdated
@snoyiatk snoyiatk force-pushed the feat/add-gitstore-branch branch from 6efd963 to 058793c Compare April 2, 2026 14:45
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 058793c73a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread internal/store/gitstore.go
Comment thread internal/store/gitstore.go
@snoyiatk
Copy link
Copy Markdown
Author

snoyiatk commented Apr 2, 2026

hi @luispater , what do you think about this?

Copy link
Copy Markdown
Collaborator

@luispater luispater left a comment

Choose a reason for hiding this comment

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

Summary: The earlier hard-coded main regression is fixed. GITSTORE_GIT_BRANCH is now optional, and the new tests cover explicit branches, empty remotes, renamed defaults, and missing branches.

Blocking findings:

  • None.

Non-blocking findings:

  • internal/store/gitstore.go:661-699 resolves the remote default branch with both a fetch and a remote listing on every branch-unset reopen. That is correct, but it makes the common sync path more network-heavy.
  • internal/store/gitstore.go:733-779 intentionally falls back to the current branch when the remote default cannot be resolved because of auth or empty-remote errors. That preserves availability, but it can leave the workspace on a stale branch until a later successful sync.

Test plan:

  • The added matrix covers the important branch-selection cases.

This is an automated Codex review result and still requires manual verification by a human reviewer.

@luispater luispater added the codex label Apr 5, 2026
@luispater luispater changed the base branch from main to dev April 6, 2026 01:20
@luispater luispater merged commit 000fcb1 into router-for-me:dev Apr 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants