-
Notifications
You must be signed in to change notification settings - Fork 1
feat(gitcommit): support custom prompt templates #31
Conversation
Add the prompt_template setting to allow customization of the prompt.
Supports %{language}, %{diff}, and %{history_context} placeholders.
Move the default prompt from git_utils.lua to config.lua.
Summary of ChangesHello @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 significantly enhances the flexibility of the git commit message generation feature by allowing users to define and utilize custom prompt templates. This change empowers users to tailor the AI's commit message output to their specific needs and conventions, moving the system towards greater configurability and user control. Highlights
🧠 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 AssistThe 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
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 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
|
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 introduces a great new feature allowing users to customize the git commit prompt via templates. The implementation is solid, moving the default prompt to the configuration and adding comprehensive documentation and tests. I have one suggestion in git_utils.lua to improve the robustness of placeholder replacement. Overall, this is a well-executed feature addition.
| end | ||
|
|
||
| local prompt = template | ||
| prompt = prompt:gsub("%%{language}", lang or "English") |
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.
For consistency and to prevent potential issues if a language name contains special gsub characters (like %), it's safer to use a function for the replacement here, just as you've done for %{diff} and %{history_context}. This ensures that the lang string is treated as a literal replacement and avoids unintended behavior from string.gsub's replacement string parsing.
prompt = prompt:gsub("%%{language}", function() return lang or "English" end)
Wrap the language placeholder replacement in a function to prevent Lua from interpreting special characters in the `lang` variable.
Add the prompt_template setting to allow customization of the prompt. Supports %{language}, %{diff}, and %{history_context} placeholders. Move the default prompt from git_utils.lua to config.lua.