Skip to main content

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 commit-for-free

Using pipx (Recommended for non-Windows platforms)

For a clean, isolated installation that doesn't interfere with your system Python:

# Install pipx if you don't have it
python -m pip install --user pipx
python -m pipx ensurepath

# Install c4f
pipx install commit-for-free

From source

  1. Clone the repository:
git clone https://github.com/alaamer12/c4f.git
cd c4f
  1. 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:

  1. Detect staged and unstaged changes in your repository
  2. Analyze the changes and their context
  3. Generate an appropriate commit message using AI
  4. Stage and commit the changes with the generated message

Command-line Options

usage: c4f [-r PATH] [-m MODEL] [-a NUM] [-t SEC] [-f]

Intelligent Git Commit Message Generator

options:
  -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.11+
  • Git
  • Required Python packages:
    • g4f
    • rich

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes using c4f itself! 😉
  4. Push to the branch (git push origin feature/amazing-feature)
  5. 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

# Run Coverage
coverage -m 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.

Changelog

See the CHANGELOG.md file for details about version history and updates.

Security

Please review our SECURITY.md file for information about:

  • How to report security vulnerabilities
  • Our responsible disclosure policy
  • Security best practices when using this tool
  • Dependency tracking and security audits

Acknowledgments

  • Built with g4f for AI generation
    • Special thanks to the g4f library maintainers for making powerful AI models accessible
    • g4f enables this tool to generate high-quality commit messages without API keys
  • Uses rich for beautiful terminal formatting

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

commit_for_free-1.0.2.tar.gz (24.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

commit_for_free-1.0.2-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file commit_for_free-1.0.2.tar.gz.

File metadata

  • Download URL: commit_for_free-1.0.2.tar.gz
  • Upload date:
  • Size: 24.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for commit_for_free-1.0.2.tar.gz
Algorithm Hash digest
SHA256 e0658fd73b07fc113ef85c387345061744bbbef12ac875b4bdf577c127187255
MD5 453010f5d4692b147b02071ade2c51fd
BLAKE2b-256 40216c31892f45f6447edef90f36964b2533e80bafa035f366cf7b87fa450a40

See more details on using hashes here.

File details

Details for the file commit_for_free-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for commit_for_free-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4eaae0fc08736ffc928dec2497706c54c5c9ef205da7aec6ab4968174daaecde
MD5 a2fe1181556edae241957cd3a502390a
BLAKE2b-256 bb20e22e0afd3818d4017d68db34a3947e755295eaad1944d3e0c26099f8af56

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page