a1da8bb97d4cdb3689f19aee674c3ca961b241ac
Auto Commit Message Generator
A Rust CLI tool that analyzes git staged changes and automatically generates conventional commit messages. It parses diffs to understand modifications and suggests appropriate messages following the Conventional Commits specification.
Features
- Automatic commit type classification: Detects feat, fix, docs, refactor, test, chore, build, ci, style, and perf commits
- Smart scope detection: Automatically extracts module/directory scope from changed files
- Interactive mode: Allows users to select/override commit type with a terminal UI
- Dry-run support: Preview commit messages without actually committing
- Multiple message options: Generates alternative commit messages for selection
Installation
From Source
git clone <repository>
cd auto-commit
cargo build --release
cargo install --path .
Prerequisites
- Rust 1.70 or later
- Git
- C compiler (gcc, clang, or MSVC) for building dependencies
Usage
Basic Usage
# Stage your changes
git add .
# Run auto-commit
auto-commit
Options
--dry-run Preview the commit message without committing
--type, -t Override the detected commit type (e.g., --type feat)
--scope, -s Override the detected scope (e.g., --scope auth)
--no-interactive Skip interactive prompts
--verbose, -v Show detailed staged changes
--help Show help message
--version Show version information
Commit Types
The tool follows the Conventional Commits specification:
| Type | Description |
|---|---|
feat |
A new feature |
fix |
A bug fix |
docs |
Documentation only changes |
style |
Changes that do not affect the meaning of the code (white-space, formatting, etc) |
refactor |
A code change that neither fixes a bug nor adds a feature |
test |
Adding missing tests or correcting existing tests |
chore |
Changes to the build process or auxiliary tools |
build |
Changes that affect the build system or external dependencies |
ci |
Changes to our CI configuration files and scripts |
perf |
A code change that improves performance |
Examples
# Interactive mode (default)
auto-commit
# Preview without committing
auto-commit --dry-run
# Force a specific commit type
auto-commit --type fix
# Override both type and scope
auto-commit --type feat --scope auth
# Non-interactive mode
auto-commit --no-interactive
Message Format
Generated messages follow the format:
<type>(<scope>): <description>
Examples:
feat(auth): add login functionalityfix(api): resolve null pointer exceptiondocs: update README with new installation instructions
Building
# Debug build
cargo build
# Release build
cargo build --release
# Run tests
cargo test
# Check formatting
cargo fmt -- --check
# Run clippy
cargo clippy -- -D warnings
License
MIT License
Description
A Rust CLI tool that analyzes git staged changes and generates conventional commit messages automatically