This project leverages AI models to intelligently generate Git commit messages. It aims to streamline the commit process by providing context-aware suggestions for commit prefixes (e.g., feat, fix, docs, chore) and concise, descriptive commit messages. This tool helps maintain a clean and standardized commit history, making collaboration and code review more efficient.
- AI-Powered Commit Generation: Utilizes advanced AI models to understand code changes and generate relevant commit messages.
- Smart Prefix Suggestions: Recommends conventional commit prefixes based on the nature of the changes.
- Concise Descriptions: Crafts clear and to-the-point descriptions for each commit.
- Command-Line Interface (CLI): Easy-to-use CLI for seamless integration into your Git workflow.
- Customizable Configuration: Allows for adjustments to AI model parameters and output formatting.
-
Clone the repository:
git clone https://github.com/your_username/git-commit-generator.git cd git-commit-generator -
Set up a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install dependencies:
pip install -r requirements.txt
-
Install the package:
pip install .
Once installed, you can use the git-commit-ai command from your Git repository's root directory.
Generate a commit message for staged changes:
git commit-aiThis command will analyze your staged changes, generate a commit message, and prompt you to confirm or edit it before committing.
Generate a commit message with a specific prompt:
git commit-ai --prompt "Refactor user authentication module"Generate a commit message and directly commit without confirmation:
git commit-ai --amendView help:
git commit-ai --helpgit-commit-generator/
├── requirements.txt
├── setup.py
├── __init__.py
├── core/
│ ├── ai_client.py
│ ├── cli.py
│ ├── config.py
│ ├── git_utils.py
│ ├── utils.py
│ └── __init__.py
└── git_commit_ai.egg-info/
├── dependency_links.txt
├── entry_points.txt
├── PKG-INFO
├── requires.txt
├── SOURCES.txt
└── top_level.txt
requirements.txt: Lists all Python dependencies.setup.py: Used for packaging and distribution.core/: Contains the main logic of the application.ai_client.py: Handles interactions with the AI model.cli.py: Implements the command-line interface.config.py: Manages application configuration.git_utils.py: Provides utility functions for Git operations.utils.py: General utility functions.
git_commit_ai.egg-info/: Metadata for the installed package.
The project relies on the following key dependencies (listed in requirements.txt):
- Python 3.7+
- [Specific AI library, e.g., OpenAI, Hugging Face Transformers]
- [Other necessary Python packages, e.g.,
clickfor CLI]
Please refer to requirements.txt for a complete and up-to-date list.
Configuration settings, such as API keys for AI models or preferred commit message formats, can be managed in core/config.py. You might also consider implementing environment variable support for sensitive information like API keys.
Example (conceptual):
# core/config.py
import os
# API key for the AI model
AI_API_KEY = os.environ.get("AI_API_KEY", "your_default_api_key")
# Model name to use
AI_MODEL_NAME = "gpt-3.5-turbo" # or another suitable model
# Prefixes for commit messages
COMMIT_PREFIXES = ["feat", "fix", "docs", "style", "refactor", "perf", "test", "chore"]We welcome contributions to git-commit-generator! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and ensure they are well-tested.
- Add tests for any new functionality.
- Update the documentation if necessary.
- Commit your changes using conventional commit messages.
- Push your branch to your fork.
- Submit a Pull Request to the main repository.
Please ensure your code adheres to the project's coding style and passes all existing tests.
This project is licensed under the MIT License - see the LICENSE file for details.