Automated Conventional Commit Message Generation Powered by Google Gemini AI
Overview • Key Features • Installation • Usage • Commit Types • Configuration • Architecture • Contributing • License
Auto Commit Message is a sophisticated tool designed to elevate your Git workflow through AI-powered commit message generation. By leveraging Google Gemini's advanced language model, this application analyzes repository changes to produce precise, standardized commit messages that follow best practices.
This tool bridges the gap between rapid development and comprehensive documentation by ensuring each commit message maintains a professional standard regardless of project complexity or team size.
- Intelligent Change Analysis: Automatically detects and interprets staged changes in your Git repository
- AI-Powered Messaging: Utilizes Google Gemini API to generate contextually accurate commit messages
- Conventional Commit Compliance: Ensures all generated messages adhere to the Conventional Commits specification
- Repository Validation: Verifies working directory is a valid Git repository before execution
- Centralized Configuration: Maintains global settings for consistent use across multiple projects
- Git Command Integration: Seamlessly integrates with Git via custom alias for frictionless workflow
- Error Handling: Robust error detection and reporting with clear guidance for resolution
- Cross-Platform Support: Compatible with Windows environments with planned expansion to macOS and Linux
- Python 3.7 or higher
- Git version 2.20 or higher
- Google Gemini API key
-
Verify Python Installation
python --version
If not available, download and install from python.org
-
Clone the Repository
git clone https://github.com/idugeni/auto-commit-message.git cd auto-commit-message
-
Execute Setup Script
setup.bat
This creates the necessary directory structure at
C:\Tools\auto-commit-message\
and copies required files. -
Install Dependencies
pip install -r requirements.txt
run the command in folder
C:\Tools\auto-commit-message\
or
pip install google-generativeai pip install python-dotenv
-
Configure API Access
Create
.env.local
inC:\Tools\auto-commit-message\
with your Google Gemini API key:GEMINI_API_KEY=your_api_key_here
-
Configure Git Alias
This document provides instructions on how to configure a Git alias for the
auto-commit-message
script. Two options are provided: one for all users (system-wide) and one for a specific user.- System-Wide Alias (All Users)
This configuration applies to all users on the system. It requires administrator privileges.
git config --system alias.acm '!C:/Program Files/Python313/python.exe C:/Tools/auto-commit-message/main.py' --replace-all
Note: This assumes Python is installed in the system-wide location
(e.g., C:/Program Files/Python313)
. Adjust the Python path if necessary.- User-Specific Alias
This configuration applies only to the current user.
git config --global alias.acm '!C:/Users/%USERNAME%/AppData/Local/Programs/Python/Python313/python.exe C:/Tools/auto-commit-message/main.py' --replace-all
Note: This uses the user-specific Python installation path. The
%USERNAME%
environment variable will be expanded to the current user's name. Adjust the Python path according to your installation if necessaryTroubleshooting
If you encounter issues creating the Git alias, the
--replace-all
option ensures that any existing alias with the same name is overwritten. If problems persist, consult the following external resources for further assistance:
-
Stage Your Changes
git add .
Or selectively stage changes for more precise commit messages:
git add <path/to/modified/files>
-
Generate and Execute Commit
git acm
The tool will:
- Analyze staged changes
- Generate a structured commit message
- Execute the commit operation
- Review Before Commit: The system will display the generated commit message and prompt for confirmation
- Custom Commit Types: The tool recognizes all standard conventional commit types (see Commit Types)
Auto Commit Message follows the Conventional Commits specification, supporting the following commit types:
Type | Description |
---|---|
build |
Changes affecting build system or external dependencies |
ci |
Changes to CI configuration files and scripts |
chore |
Routine maintenance tasks and minor changes |
docs |
Documentation-only changes |
feat |
Introduction of new features |
fix |
Bug fixes |
perf |
Performance improvements |
refactor |
Code changes that neither fix bugs nor add features |
revert |
Reverts a previous commit |
style |
Changes not affecting code functionality (formatting, etc.) |
test |
Adding or correcting tests |
security |
Security-related improvements or fixes |
The system uses a centralized configuration file at C:\Tools\auto-commit-message\.env.local
containing the following parameters:
GEMINI_API_KEY
: Your Google Gemini API authentication key
Advanced users can modify the following parameters in main.py
:
temperature
: Controls creativity level (0.0-1.0)top_p
: Nucleus sampling parameter for response diversitytop_k
: Limits vocabulary choices for each token predictionmax_output_tokens
: Maximum response length
auto-commit-message
├─ .github # GitHub config
│ ├─ ISSUE_TEMPLATE # Issue templates
│ │ ├─ bug_report.md # Bug report
│ │ ├─ custom.md # Custom issues
│ │ └─ feature_request.md # Feature request
│ └─ FUNDING.yml # Funding info
├─ __init__.py # Package init
├─ .gitignore # Git ignore
├─ ai_manager.py # AI manager
├─ CODE_OF_CONDUCT.md # Code of conduct
├─ config.py # Config settings
├─ env_manager.py # Env manager
├─ exceptions.py # Exceptions
├─ git_manager.py # Git manager
├─ LICENSE # License info
├─ logging_setup.py # Logging setup
├─ main.py # Main logic
├─ models.py # Models
├─ README.md # Docs
├─ requirements.txt # Dependencies
├─ SECURITY.md # Security policy
└─ setup.bat # Windows setup
-
Environment Validation:
- Checks for valid Git installation
- Verifies current directory is a Git repository
- Validates API key configuration
-
Change Analysis:
- Retrieves staged changes via
git diff --cached
- Preprocesses diff content for AI analysis
- Retrieves staged changes via
-
Message Generation:
- Submits preprocessed changes to Google Gemini API
- Applies structured prompt with formatting requirements
- Receives AI-generated commit message
-
Commit Execution:
- Displays generated message for review
- Executes commit operation with validated message
We welcome contributions to improve Auto Commit Message! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-improvement
) - Commit your changes using conventional commits (
feat: add amazing improvement
) - Push to your branch (
git push origin feature/amazing-improvement
) - Open a Pull Request
For more details, please review our Code of Conduct and Security Policy.
This project is licensed under the MIT License - see the LICENSE file for details.
Elevate your Git workflow with AI-powered commit messages
Made with precision and care by idugeni