A sophisticated Git commit message generator that uses AI to create meaningful, conventional commit messages based on your code changes.
Project description
C4F - Commit For Free
A sophisticated Git commit message generator that uses AI to create meaningful, conventional commit messages based on your code changes.
_____ _ _ _____
/ ____| || | | ___|
| | | || |_ | |_
| | |__ _| | _|
| |____ | | | |
\_____| |_| |_|
Commit For Free - AI-Powered Git Commit Message Generator
Features
- 🤖 AI-powered commit message generation using GPT models
- 📝 Follows Conventional Commits format
- 🔍 Smart analysis of file changes and diffs
- 🎨 Beautiful CLI interface with rich formatting
- ⚡ Efficient handling of both small and large changes
- 🔄 Fallback mechanisms for reliability
- 🎯 Automatic change type detection (feat, fix, docs, etc.)
- 📊 Progress tracking and status display
Installation
Using pip
pip install c4f
From source
- Clone the repository:
git clone https://github.com/alaamer12/c4f.git
cd c4f
- Install using Poetry:
poetry install
Or with pip:
pip install -e .
Usage
Basic Usage
Simply run the command in your Git repository:
c4f
The tool will:
- Detect staged and unstaged changes in your repository
- Analyze the changes and their context
- Generate an appropriate commit message using AI
- Stage and commit the changes with the generated message
Command-line Options
usage: c4f [-h] [-v] [-r PATH] [-m MODEL] [-a NUM] [-t SEC] [-f]
Intelligent Git Commit Message Generator
options:
-h, --help Show this help message and exit
-v, --version Show program's version number and exit
-r PATH, --root PATH Set the root directory for git operations [default: current project root]
-m MODEL, --model MODEL
Set the AI model to use for commit message generation [default: gpt-4-mini]
Choices: gpt-4-mini, gpt-4, gpt-3.5-turbo
Generation Options:
Configure the commit message generation process
-a NUM, --attempts NUM
Set the number of generation attempts before falling back [default: 3]
Range: 1-10
-t SEC, --timeout SEC
Set the fallback timeout in seconds for model response [default: 10]
Range: 1-60
Formatting Options:
Configure the commit message format
-f, --force-brackets Force conventional commit type with brackets (e.g., feat(scope): message)
Examples
Generate commit messages with the default settings:
c4f
Use a specific AI model:
c4f --model gpt-4
Set custom generation parameters:
c4f --attempts 5 --timeout 20
Force brackets in conventional commit format:
c4f --force-brackets
Specify a different root directory:
c4f --root /path/to/your/repo
Features in Detail
- Smart Change Analysis: Automatically detects the type of changes (feature, fix, documentation, etc.) based on file paths and content
- Comprehensive Messages: Generates detailed commit messages for larger changes with bullet points and breaking change notifications
- Interactive Interface: Displays changes in a formatted table and allows user interaction when needed
- Progress Tracking: Shows real-time progress for file analysis and commit operations
- Fallback Mechanism: Includes a fallback system if AI generation fails or times out
Configuration
Key configuration options available through command-line arguments:
| Option | Description | Default |
|---|---|---|
--model |
AI model to use | gpt-4-mini |
--attempts |
Number of message generation attempts | 3 |
--timeout |
Timeout in seconds for AI response | 10 |
--force-brackets |
Force brackets in conventional format | False |
Requirements
- Python 3.9+
- Git
- Required Python packages:
- g4f
- rich
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes using c4f itself! 😉
- Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development Setup
# Clone the repository
git clone https://github.com/alaamer12/c4f.git
cd c4f
# Install development dependencies
poetry install --with dev
# Run tests
pytest
Model Compatibility
While c4f has been primarily tested with gpt-4-mini, gpt-4, and gpt-3.5-turbo, the underlying g4f library supports many additional models. However, please note:
⚠️ Warning: Although most g4f-supported models may technically work with c4f, they have not been extensively tested and are not officially recommended. Using untested models may result in:
- Lower quality commit messages
- Slower performance
- Unexpected errors or timeouts
For the best experience, we recommend using one of the officially supported models specified in the command-line options.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file commit_for_free-1.0.0.post1.tar.gz.
File metadata
- Download URL: commit_for_free-1.0.0.post1.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e33d602cb83f45a447376be1b8d69b0368cfe387d48be41708bd5c152afbc76
|
|
| MD5 |
bd52210ae0103d833324784b937eae1d
|
|
| BLAKE2b-256 |
1895ed50df607a0199c2bc533d26f58ffcbab4e40dd50cfe351a867a03149162
|
File details
Details for the file commit_for_free-1.0.0.post1-py3-none-any.whl.
File metadata
- Download URL: commit_for_free-1.0.0.post1-py3-none-any.whl
- Upload date:
- Size: 19.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b627c854e59323de49a05e95c6d7ed11030835494d39947be8f55add4122d1e
|
|
| MD5 |
1a63b1d37c99800d27043f7d314b1305
|
|
| BLAKE2b-256 |
69cfc3f79a663592ac161cdd406c652fc14e4bd2cb492c2907d14b688029fca5
|