https://github.com/adelelawady/ai-git-commit
This repository contains scripts that automatically generate meaningful Git commit messages using AI. scripts analyze your code changes and create descriptive commit messages, with optional emoji support.
https://github.com/adelelawady/ai-git-commit
Last synced: over 1 year ago
JSON representation
This repository contains scripts that automatically generate meaningful Git commit messages using AI. scripts analyze your code changes and create descriptive commit messages, with optional emoji support.
- Host: GitHub
- URL: https://github.com/adelelawady/ai-git-commit
- Owner: adelelawady
- License: mit
- Created: 2025-01-06T18:09:09.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-06T18:24:51.000Z (over 1 year ago)
- Last Synced: 2025-01-06T19:26:01.008Z (over 1 year ago)
- Language: Python
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AI Git Commit Message Generator đ¤ â¨




This repository contains two scripts that automatically generate meaningful Git commit messages using AI. Both scripts analyze your code changes and create descriptive commit messages, with optional emoji support.
## Scripts Overview đ
### 1. Generate.py (Ollama Version) đŗ

Uses Ollama's local AI model to generate commit messages.
**Features:**
- đ Local AI processing with Ollama
- đ Analyzes both staged and unstaged changes
- đ Watch mode for automatic commits
- đ Optional emoji in commit messages
- đ Detailed change summaries
- đ¯ Support for staged-only commits
**Requirements:**
- Python 3.x
- Ollama installed and running
- qwen2.5-coder:3b model in Ollama
### 2. Generate_Hyperbolic.py (Cloud Version) âī¸

Uses Hyperbolic's cloud API for commit message generation.
**Features:**
- đ Cloud-based AI processing
- đ Analyzes both staged and unstaged changes
- đ Watch mode for automatic commits
- đ Optional emoji in commit messages
- đ Detailed change summaries
- đ¯ Support for staged-only commits
**Requirements:**
- Python 3.x
- Hyperbolic API key
- Internet connection
## Installation đ ī¸
### Option 1: Install all dependencies
```bash
# Windows
pip install -r .\requirements.txt
# Linux/Mac
pip install -r requirements.txt
```
### Option 2: Install in virtual environment (recommended)
```bash
# Create virtual environment
python -m venv venv
# Activate virtual environment
# Windows
.\venv\Scripts\activate
# Linux/Mac
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
```
### Option 2: Install individual packages
1. Install required packages:
```bash
pip install gitpython watchdog
```
2. For generate.py
```bash
pip install ollama-python
```
3. For generate_hyperbolic.py
```bash
pip install requests
```
## Usage đ
### Basic Usage:
```bash
python generate.py
```
## Using Ollama version
```bash
python generate.py
```
## Using Hyperbolic version
```bash
python generate_hyperbolic.py
```
### Command Line Options đŽ
Both scripts support the following options:
| Option | Short | Description |
|--------|-------|-------------|
| `--path` | `-p` | Path to Git repository (default: current directory) |
| `--emoji` | `-e` | Enable emoji in commit messages |
| `--staged` | `-s` | Only process staged files |
| `--watch` | `-w` | Enable watch mode for automatic commits |
| `--delay` | `-d` | Delay in seconds before auto-commit (default: 5) |
| `--debug` | | Enable debug logging |
### Examples đ
```bash
python generate.py -p /path/to/repo -e -s -w -d 10
```
## Watch mode with emojis
```bash
python generate.py -w -e
```
## Process only staged changes
```bash
python generate.py -s
```
## Watch staged changes with custom delay
```bash
python generate.py -w -s -d 10
```
## Use specific repository path
```bash
python generate.py -p /path/to/repo
```
## Features in Detail đ
### Watch Mode đ
- Monitors repository for changes
- Automatically generates commit messages
- Configurable delay before commit
- Can be limited to staged changes only
### Emoji Support đ
- Adds relevant emojis based on change type
- Follows conventional commit message format
- Makes commits more expressive and readable
### Logging đ
- Detailed debug logs available
- UTF-8 support for emoji logging
- Tracks all operations and errors
## Error Handling đĄī¸
- Graceful handling of Git errors
- API connection error management
- Unicode/encoding error protection
- Duplicate processing prevention
## Contributing đ¤
Feel free to submit issues and enhancement requests!
## License đ
MIT License
## Note âšī¸
- The Ollama version (generate.py) requires a local Ollama installation
- The Hyperbolic version (generate_hyperbolic.py) requires an API key and internet connection
- Both scripts provide similar functionality with different AI backends
```
python .\generate_hyperbolic.py --watch --staged --emoji --delay 2 -p /path/to/proj
```