Comsu is a simple yet powerful command-line tool that leverages Google Generative AI to suggest high-quality, concise commit messages based on your staged changes in Git. Automate the process of writing meaningful commit messages and ensure consistency across your project.
- Automated Commit Messages: Generate commit messages based on your staged changes using Google's AI model.
- Auto Commit: It can automatically commit your changes with your selected commit message.
- Supports Conventional Commit Types: Suggestions follow the standard commit types (
feat,fix,build,chore, etc.). - Easy Setup: One-command installation to get started.
- Customizable Prompts: Modify the prompt file to tailor the AI suggestions to your specific project needs.
Linux
To set up Comsu on your Linux system, follow these steps:
-
Clone the Repository:
git clone https://github.com/ali-hv/comsu.git cd comsu -
Run the Installation Script:
chmod +x install.sh sudo ./install.sh
-
Set Your API Key:
Make sure you have your Google AI Studio API key set as an environment variable. If you don’t have one, you can create a free API key here.
export GOOGLE_AI_STUDIO_API_KEY="your_api_key_here"
You can add this line to your
~/.bashrcor~/.zshrcto make it persistent.
Windows
To set up Comsu on your Windows system, follow these steps:
-
Clone the Repository: open powershell as administrator, then write these commands:
git clone https://github.com/ali-hv/comsu.git cd comsu
-
Run the Installation Script:
powershell -ExecutionPolicy Bypass -File install.ps1
-
Set Your API Key:
Make sure you have your Google AI Studio API key set as an environment variable. If you don’t have one, you can create a free API key here.
Temporary Session Setting: This method sets the environment variable only for the duration of your current Command Prompt session:set GOOGLE_AI_STUDIO_API_KEY=your_api_key_herePersistent Setting: To make the environment variable persistent across sessions, you can use the following method, which sets the environment variable permanently for your user profile:setx GOOGLE_AI_STUDIO_API_KEY "your_api_key_here"
Once installed, you can run Comsu from any directory where you have staged changes:
Linux
git comsuWindows
Run this in the cmd:
git-comsuIf you live in countries restricted by Google, you may want to use a VPN or change your DNS.
This will generate a list of suggested commit messages based on your changes and you can choose the message you want, then it will automatically commit your changes with that message. If you don't like any of the messages, you can type 'x' to exit.
Example
git add .
git comsuOutput:
Generating the commit messages based on your changes ...
1. ref: Refactor the send_email function for efficiency
2. ref: Update the send_email to reduce processing time
3. feat: Use new method for getting the changes in send_email
Write the message number you want to use (write 'x' to exit): 1
[main 6b25961] ref: Refactor the send_email function for efficiency
1 file changed, 1 deletion(-)
Committed successfully.
The prompt used to generate the commit messages is stored in a file named prompt located at /usr/local/share/git-comsu/prompt. You can modify this file to change the way AI generates the commit messages.
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
- Fork the repository.
- Create your feature branch (git checkout -b feature/new-feature).
- Commit your changes (git commit -m 'Add some feature').
- Push to the branch (git push origin feature/new-feature).
- Open a Pull Request.
If you find this tool helpful, please give a ⭐ to the repository!