CommitKit is a command-line tool that helps developers create well-structured and consistent commit messages following the Conventional Commits specification. It provides an interactive interface to guide users through the process of constructing a commit message with a type, optional scope, subject, body, and footer.
-
Core Functionality
- Interactive selection of commit types and scopes
- Customizable configuration via
.commitkit.toml - Enforcement of maximum subject length
- Support for multi-line commit bodies
- Automatic validation of input
- Optional signed-off commits
- Cross-platform compatibility
-
Enhanced Features
- Emoji support in commit messages (✨, 🐛, etc.)
- Commit templates with placeholder substitution
- Automatic changelog generation and maintenance
- Git hooks for commit message validation and formatting
- Commit statistics and analysis
- Interactive prompts for template values
- Rust: Version 1.88.0 or higher (MSRV)
- Cargo: Included with Rust installation
git clone https://github.com/somethingwithproof/commitkit-rust.git cd commitkit-rust cargo install --path .
Navigate to your git repository and run:
commitkit
USAGE:
commitkit [OPTIONS]
OPTIONS:
-d, --dry-run Skip git commit and print the message to stdout
-v, --verbose Show verbose output
-c, --config Path to config file (default: .commitkit.toml in current or home directory)
--emoji Toggle emoji in commit messages
--template Use a specific commit template
--changelog Update changelog after committing
--install-hooks Install git hooks
--stats Show commit statistics
--days Number of days to analyze for stats (default: all)
--validate Validate a commit message file
--prepare-msg Prepare commit message (used by git hook)
-h, --help Print help information
-V, --version Print version information
The tool will guide you through the process of creating a conventional commit message:
- Select a commit type (feat, fix, docs, etc.)
- Select a scope (optional)
- Enter the commit subject
- Enter the commit body (optional)
- Enter the commit footer (optional)
After completing these steps, CommitKit will run git commit with your constructed message.
# Basic usage commitkit # Dry run - display the resulting commit message without committing commitkit --dry-run # Use a custom config file commitkit --config /path/to/custom-config.toml # Verbose output commitkit --verbose # Use emojis in commit messages commitkit --emoji # Use a template for your commit commitkit --template feature # Automatically update CHANGELOG.md commitkit --changelog # Install git hooks commitkit --install-hooks # Show commit statistics for the last 30 days commitkit --stats --days 30 # Validate a commit message commitkit --validate .git/COMMIT_EDITMSG
# Debug build cargo build # Release build cargo build --release
# Run all tests cargo test # Run tests with output cargo test -- --nocapture
# Check for linting issues cargo clippy --all-targets --all-features # Apply automatic fixes cargo clippy --fix --allow-dirty
# Check formatting cargo fmt -- --check # Apply formatting cargo fmt
CommitKit looks for a configuration file named .commitkit.toml in the following locations (in order):
- Current directory
- User's home directory
If no configuration file is found, a default one will be generated in your home directory.
Example configuration:
# CommitKit Configuration # Whether to add a Signed-off-by line to commits (-s flag) sign_off_commits = false # Commit message prefixes following Conventional Commits specification prefixes = [ { title = "feat", description = "A new feature" }, { title = "fix", description = "A bug fix" }, { title = "docs", description = "Documentation changes" }, { title = "style", description = "Changes that do not affect code meaning" }, { title = "refactor", description = "Code change that neither fixes a bug nor adds a feature" }, { title = "perf", description = "Code change that improves performance" }, { title = "test", description = "Adding missing tests or correcting existing tests" }, { title = "build", description = "Changes that affect the build system or external dependencies" }, { title = "ci", description = "Changes to CI configuration files and scripts" }, { title = "chore", description = "Other changes that don't modify src or test files" }, { title = "revert", description = "Reverts a previous commit" } ] # Optional scopes to categorize changes scopes = [ "core", "ui", "docs", "tests", "deps" ] # Subject line length constraints max_subject_len = 72 min_subject_len = 3 # Feature toggles use_emoji = true # Add emojis to commit messages update_changelog = true # Update CHANGELOG.md automatically validate_commit_msg = true # Validate commit messages against conventional format # Templates directory for custom commit templates templates_dir = "~/.commitkit/templates"
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Feel free to open issues or submit pull requests.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes using conventional commits
- Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request