GitConvit, an AI-powered tool that generates conventional commit messages with emojis based on the changes in your Git repository.
This tool leverages the llama3:latest
model from ollama
to create commit messages that follow conventional commit standards, ensuring that your commit history is informative and well-structured.
- Automatically detects changes in your Git repository.
- Generates conventional commit messages with appropriate emojis.
- Interactive prompt to confirm or regenerate the commit message along other options.
- Ensures that all changes are committed with a single, informative message.
The following categories and emojis are used for generating commit messages:
docs
: 📝feat
: ✨fix
: 🐛style
: 🎨refactor
: 🔨chore
: 🚀config
: ⚙️
- Install
ollama
:- Download and install
ollama
from ollama's official website. - Ensure that
ollama
is running and accessible athttp://localhost:11434
. - Pull the
latest
version of thellama3
model. with the following command:ollama pull llama3:latest
- Download and install
- Install
gum
(Optional for Enhanced UI/UX):- If you want to use the
gum
enhanced script:# macOS or Linux brew install gum # Arch Linux (btw) pacman -S gum # Windows (via WinGet or Scoop) winget install charmbracelet.gum scoop install charm-gum
- More installation methods here.
- If you want to use the
To cater to different user preferences and environments, we provide three versions of the script:
-
Python Script (
script.py
):- For users who prefer Python and want a straightforward approach without additional dependencies.
-
Bash Script without Dependencies (
script.sh
):- For users who prefer a bash script without any additional dependencies. This version has a basic user interface and functionality.
-
Bash Script with
gum
(gumscript.sh
):- For users who want a significantly enhanced user experience with a modern, interactive UI. This version requires the
gum
tool to be installed.
- For users who want a significantly enhanced user experience with a modern, interactive UI. This version requires the
You can choose the version that best fits your needs and preferences.
-
Clone the Repository:
git clone https://github.com/Osama-Yusuf/GitConvit.git cd GitConvit
-
Make the Script Executable:
chmod +x gumscript.sh
-
Install Dependencies:
- Ensure you have
jq
installed for processing JSON responses:sudo apt-get install jq
- Ensure you have
-
Add the Script to your bin directory:
sudo cp gumscript.sh /usr/local/bin/gitconvit
To generate and use a conventional commit message, run the script:
gitconvit
- Check if you are in a Git repository.
- Detect the changed files.
- Generate a commit message using the AI model.
- Prompt you to confirm or regenerate the commit message.
- Commit and push the changes to your repository.
-
Check if the Current Directory is a Git Repository:
- The script ensures that the current directory is a Git repository before proceeding.
-
Get Changed Files and Diffs:
- The script uses
git diff --name-only
andgit diff
to get the list of changed files and their diffs.
- The script uses
-
Generate Commit Message:
- The script sends the changes to the AI model
llama3:latest
fromollama
to generate a conventional commit message with an appropriate emoji. - The commit message follows the format specified by conventional commits.
- The script sends the changes to the AI model
-
Interactive Confirmation:
- The script prompts you to either accept the generated commit message, regenerate it by pressing
r
, or abort by pressingCTRL+C
.
- The script prompts you to either accept the generated commit message, regenerate it by pressing
-
Commit and Push:
- Once confirmed, the script adds all changes, commits them with the generated message, and pushes to the current branch.
Here is an example of how the commit message might look:
📝 docs(README.md): added installation method with docker
- Add a flag to select different ollama model than llama3
- Add a flag to select different ai model than ollama like openai models or google gemeni or grok
- Add a tutorial GIF in the readme file
- Add an (add) option that will list all files changed and user can multiselect files with gum/fzf/case
- Make the emojis optional
- Add an option to edit the AI output
- Add an option to pass a prompt to the initial main prompt
- Add an option to create the convential commit manually by taking three inputs the category, the context, and a short description
- Add an option to recreate the AI output
Contributions are welcome! Please fork the repository and create a pull request with your changes.
This project is licensed under the MIT License. See the LICENSE file for details.
For any inquiries or support, please contact Osama Yusuf.