Skip to content

feat: add git state check on startup#20

Merged
axeldelafosse merged 3 commits intomainfrom
feat/git-state-check
Feb 28, 2026
Merged

feat: add git state check on startup#20
axeldelafosse merged 3 commits intomainfrom
feat/git-state-check

Conversation

@axeldelafosse
Copy link
Copy Markdown
Owner

Summary

  • Show a heads-up warning when on a non-main branch or when local main/master is behind the remote, so the user notices before starting a loop session
  • Update review prompt to focus on unstaged changes (git diff) rather than inspecting all changed files
  • Sync AGENTS.md/README.md wording ("dead-simple", 150-line limit)

Test plan

  • New unit tests for checkGitState covering all branches (non-main, behind remote, up to date, no git, no upstream)
  • Existing CLI tests updated to mock checkGitState
  • bun run check passes
  • All 237 tests pass

Show a heads-up warning when the user is on a non-main branch or when
local main/master is behind the remote, so they notice before starting
a loop session.
@gemini-code-assist
Copy link
Copy Markdown

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 enhances the user experience by introducing proactive Git state checks at application startup, providing warnings if the user is not on a main branch or if their local main/master branch is behind the remote. Additionally, it improves the clarity of the review process by directing reviewers to concentrate on unstaged changes, and updates documentation consistency.

Highlights

  • Git State Check: Implemented a Git state check on startup to warn users about non-main branches or outdated local main/master branches.
  • Review Prompt Refinement: Refined the review prompt to guide reviewers to focus on unstaged changes using git diff.
  • Documentation Consistency: Standardized wording in AGENTS.md and README.md, including updating the src/loop/main.ts line limit to 150.
Changelog
  • AGENTS.md
    • Updated the recommended line limit for src/loop/main.ts from 100 to 150.
    • Changed 'dead simple' to 'dead-simple'.
  • README.md
    • Changed 'Dead simple' to 'Dead-simple'.
  • src/cli.ts
    • Integrated a call to checkGitState at startup.
    • Displayed a warning message to the console if checkGitState returns one.
  • src/loop/deps.ts
    • Imported checkGitState from ./git.
    • Exported checkGitState as part of cliDeps.
  • src/loop/git.ts
    • Defined MAIN_BRANCHES set for 'main' and 'master'.
    • Implemented checkGitState function to verify the current branch and its sync status with the remote.
    • checkGitState returns a warning string if on a non-main branch or if main/master is behind remote, otherwise undefined.
  • src/loop/prompts.ts
    • Modified buildReviewPrompt to explicitly instruct reviewers to focus on unstaged changes (git diff).
  • tests/loop.test.ts
    • Updated CliModuleDeps interface to include checkGitState.
    • Added checkGitStateMock to loadRunCli and mock.module setup.
    • Exported checkGitStateMock from loadRunCli return.
  • tests/loop/git.test.ts
    • Added a new test file dedicated to checkGitState.
    • Included tests for non-main branch, local main/master behind remote, up-to-date main, non-Git repo, and no upstream scenarios.
Activity
  • New unit tests were added for the checkGitState function, covering various Git scenarios like non-main branches, local branches behind remote, up-to-date branches, and cases without Git or upstream.
  • Existing CLI tests were updated to properly mock the new checkGitState functionality.
  • The author confirmed that bun run check passes.
  • All 237 existing tests were verified to pass after the changes.
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

@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 helpful feature to warn users about their git repository state on startup, specifically if they are on a non-main branch or their main branch is behind the remote. The implementation is solid, with good use of dependency injection and comprehensive unit tests for the new logic. The changes to prompts and documentation are also clear. I have one suggestion to improve the structure of the new tests for better readability and maintainability.

Comment thread tests/loop/git.test.ts
@axeldelafosse axeldelafosse merged commit 3cb0052 into main Feb 28, 2026
2 checks passed
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