-
Notifications
You must be signed in to change notification settings - Fork 1
refactor(gitcommit): improve auto-generation reliability for commit m… #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…essages - enhance auto-generation mechanism with multiple event triggers - add stable timing detection for different Git tools - implement debounce and tracking to prevent duplicate generations - support graceful handling of buffer states and Git operations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @jinzhongjia, 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 refactors the auto-generation logic for Git commit messages to significantly improve its reliability and compatibility across different Git workflows and tools. It introduces a more robust event-triggering system, incorporates stable timing detection, and implements mechanisms to prevent duplicate generations, ensuring that commit messages are generated accurately and efficiently while respecting user intent and buffer states.
Highlights
- Enhanced Auto-Generation Triggers: The auto-generation mechanism for commit messages has been significantly improved by introducing multiple event triggers, including
WinEnter,BufWinEnter, andCursorMoved, to ensure broader compatibility with various Git tools like Fugitive. - Stable Timing and Debouncing: A new
schedule_auto_generatefunction with an extended delay and debouncing logic has been implemented to provide stable timing detection, preventing race conditions and ensuring commit messages are generated reliably and only once. - Duplicate Generation Prevention: The system now tracks whether auto-generation has already been attempted for a buffer (
auto_generate_attemptedflag) and cancels pending timers to prevent duplicate commit message generations. - Graceful Buffer and Git Operation Handling: A
should_attempt_auto_generatefunction was added to gracefully handle various buffer states, such as checking for existing commit messages, validating the buffer, and respecting theskip_auto_generate_on_amendconfiguration during Git amend operations. - Resource Cleanup: Autocmds for
BufDeleteandBufUnloadhave been added to ensure that any pending auto-generation timers are properly stopped and cleaned up when a buffer is closed or unloaded.
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
-
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. ↩
There was a problem hiding this 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 significantly improves the reliability of the automatic commit message generation by introducing multiple event triggers, debouncing, and better state management. The changes are well-structured and address the core goal of improving stability with different Git tools. I have a couple of suggestions to further enhance reliability and maintainability, primarily by refactoring the autocommand setup and addressing a magic number. Overall, this is a solid improvement.
- consolidate autocmd callbacks to reduce code duplication - add configurable window stability delay - simplify autocmd registration with shared callback - remove redundant callback definitions in event triggers
- Add new sections for memory configuration and usage - Update Claude Code, ACP, and adapter setup documentation - Remove treesitter dependency references - Update system prompt with more flexible language and date handling - Enhance documentation for prompt libraries and memory parsers
…essages