Skip to content

feat(gitcommit): add commit history context for message generation #9

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

Merged
merged 12 commits into from
Jul 25, 2025

Conversation

jinzhongjia
Copy link
Owner

  • introduce use_commit_history and commit_history_count options to include recent commit messages as context
  • update generator to pass commit history to LLM prompt for improved style consistency
  • implement Git.get_commit_history to retrieve recent commit messages from git log
  • update configuration, types, and example config to support and document the new feature
  • ensure commit history context is used across buffer, init, and generator modules

- introduce `use_commit_history` and `commit_history_count` options to include recent commit messages as context
- update generator to pass commit history to LLM prompt for improved style consistency
- implement `Git.get_commit_history` to retrieve recent commit messages from git log
- update configuration, types, and example config to support and document the new feature
- ensure commit history context is used across buffer, init, and generator modules
Copy link

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

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 introduces a significant enhancement to the gitcommit extension by enabling the use of recent commit history as context for LLM-generated commit messages. The primary goal is to improve the consistency and quality of generated messages by allowing the AI to learn from the project's existing commit style, tone, and format, leading to more coherent and contextually relevant suggestions.

Highlights

  • Enhanced LLM Context for Commit Messages: Introduced new configuration options (use_commit_history and commit_history_count) to allow the LLM to consider recent commit messages as context when generating new ones.
  • Improved Style Consistency: The LLM prompt now incorporates a configurable number of past commit messages, guiding the model to generate new messages that align with the project's established commit style and format.
  • Git History Retrieval: Implemented a new utility function (Git.get_commit_history) to efficiently retrieve recent commit messages directly from the Git log, supporting the new context feature.
  • Broad Integration: The commit history context is seamlessly integrated across the buffer, init, and generator modules, ensuring the feature is available wherever commit messages are generated.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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

@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 valuable feature to use commit history as context for generating new commit messages, which should improve consistency. The implementation is mostly solid, but there are a few areas that need attention to maintain code quality, particularly regarding type definitions and code duplication.

- update indentation and spacing across gitcommit extension files
- fix minor comment alignment and trailing comma issues in config example
- standardize function parameter documentation and formatting
- move generate_commit_message function from Git class to proper Generator class
- add missing get_commit_history function declaration to Git class
- fix indentation and formatting issues in type annotations
- delete extraneous blank line for improved code readability
- consolidate EXTENSION_DEVELOPMENT_GUIDE.md, GEMINI.md, tools.md, and prompt_construction_en.md into codecompanion.txt
- update and expand help documentation for plugin features, configuration, extension development, and tool creation
- remove outdated and redundant markdown guides in favor of unified vim help file
- update comments and docstrings for clarity and consistency across buffer, generator, git, init, and ui modules
- rephrase and simplify inline comments to enhance readability
- standardize parameter descriptions and function documentation for better maintainability
- add commit history context feature to README and configuration docs
- introduce programmatic API section with usage examples in README and help file
- update documentation structure and configuration options for clarity
- introduce codecompanion-workspace.json with schema and group definitions
- organize extension components into logical groups for core, git, AI, UI, tools, and docs
- provide metadata and file descriptions to support project tooling and documentation
- add documentation for the get_changed_files tool, including usage and options
- update tool group listings and examples to include get_changed_files
- clarify and expand options for file_search, grep_search, insert_edit_into_file, and next_edit_suggestion tools
- update event list with CodeCompanionChatDone event
- fix and improve tool group documentation for clarity and completeness
- add checks for nil language selection in commit message generation
- prevent further processing if user cancels language selection dialog
- clean up unnecessary whitespace for improved code consistency
- document Git.setup with LuaDoc annotation for configuration options
- simplify git_config retrieval in generate_commit_message by removing redundant check
@jinzhongjia jinzhongjia merged commit 5411c45 into main Jul 25, 2025
1 check 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