-
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