-
Notifications
You must be signed in to change notification settings - Fork 145
Open
Description
📋 Overview
Writing meaningful Git commit messages is often skipped or done poorly. This project automates commit message generation by summarizing code changes with a small, offline LLM the Flan-T5 model ensuring it works on any machine without a GPU.
🎯 Objectives
- Automatically generate descriptive commit messages from Git diffs.
- Maintain a lightweight, offline workflow suitable for developers with CPU-only machines.
- Provide an easy-to-use CLI or pre-commit hook integration.
⚙️ Features
- Diff Analysis: Extracts staged Git changes.
- AI Commit Generation: Uses Flan-T5 to generate human-readable messages.
- Commit Type Support: Optionally categorize messages as
feat,fix,docs, etc. - CLI Interface: Quick command-line usage:
python commitgen.py --type feat- Offline & CPU-Friendly: No GPU required; runs on small laptops or cloud servers.
🧩 Tech Stack
- Python 3.12+
- Libraries:
transformers,torch,argparse,subprocess
📂 Project Structure
ai-commit-gen/
├── commitgen.py # CLI tool
├── utils.py # Git diff extraction and helpers
├── requirements.txt
├── README.md
└── examples/
└── sample_diff.txt
🧪 Example Workflow
# Stage changes
git add .
# Generate AI commit message
python commitgen.py --type feat
# Output:
# ✨ Suggested Commit:
# "feat(auth): refactored login validation and added password length checks"🚀 Advantages
- Fully offline, CPU-compatible, no API keys required.
- Lightweight (Flan-T5 small model ~240 MB).
- Improves commit quality and project maintainability.
Metadata
Metadata
Assignees
Labels
No labels