A CLI tool for generating commit messages using Google Generative AI
GPL-3.0 License
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.
feat
, fix
, build
, chore
, etc.).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 ~/.bashrc
or ~/.zshrc
to make it persistent.
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.
set GOOGLE_AI_STUDIO_API_KEY=your_api_key_here
You can add this line to your $PATH to make it persistent.
Once installed, you can run Comsu from any directory where you have staged changes:
git comsu
Run this in the cmd:
git-comsu
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 comsu
Output:
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.
If you find this tool helpful, please give a β to the repository!