Auto-Gitmoji ๐
A Rust CLI tool that automatically prepends appropriate gitmoji to your commit messages based on intelligent keyword matching.
โจ Features
- ๐ฏ Simple KeywordMatching: Enhanced first-word keyword matching with 200+ keyword mappings
- ๐ฏ LLM KeywordMatching: AI-powered matching with LLM(now only support SiliconFlow)
- ๐จ Comprehensive Emoji Support: All 69 official gitmojis from the gitmoji standard
- โก Git Integration: Seamless integration with your Git workflow
- ๐ Dry Run Mode: Preview commits before executing
- ๐ Emoji Display: View all available gitmojis with Unicode rendering
- ๐ก๏ธ Robust Error Handling: Validates staged changes and Git repository status
- ๐งช Comprehensive Testing: 65 tests covering unit, integration, and edge cases
- ๐ Enhanced CLI Experience: ANSI colors, progress indicators, and user-friendly output
๐ฎ Future Features
- Support for more LLM APIs
- Custom keyword mapping configuration
- Integration with commit message templates
๐ Installation
Prerequisites
- Rust 1.70+ with Cargo
- Git installed and configured
From Source
From Crates.io
# or with your own API_KEY
๐ Usage
Basic Usage
# Commit with automatic gitmoji selection
# Output: โจ :sparkles: add new user authentication feature
# Preview without committing (dry run)
# Output: ๐ :bug: fix login validation bug
# Show all available emojis
# Get detailed help with examples
Complete Examples
# Feature additions
# Result: โจ :sparkles: add user profile page
# Bug fixes
# Result: ๐ :bug: fix memory leak in data processor
# Hotfixes
# Result: ๐๏ธ :ambulance: hotfix critical authentication vulnerability
# Documentation
# Result: ๐ :memo: docs update installation guide
# Refactoring
# Result: โป๏ธ :recycle: refactor authentication module
# Performance improvements
# Result: โก :zap: optimize database query performance
# Testing
# Result: ๐งช :test_tube: test user registration flow
# Dependencies
# Result: ๐ฆ :package: update package dependencies
# Security
# Result: ๐ :lock: security fix for JWT validation
๐ฏ How It Works
Enhanced Keyword Matching Strategy
- ๐ Analysis: Commit message analyzed word by word
- ๐งน Cleaning: Non-alphanumeric characters replaced with spaces for better word extraction
- ๐ Extraction: Words split by whitespace and normalized to lowercase
- ๐ฏ Matching: First word matched against comprehensive keyword database
- โจ Formatting: Complete commit message formatted with appropriate gitmoji
Keyword Categories
Category | Keywords | Emoji |
---|---|---|
Features | add , new , create , implement , introduce , feat |
โจ :sparkles: |
Bug Fixes | fix , repair , resolve , correct , patch |
๐ :bug: |
Hotfixes | hotfix , urgent , critical |
๐๏ธ :ambulance: |
Documentation | docs , documentation , readme , comment |
๐ :memo: |
Refactoring | refactor , restructure , reorganize , cleanup |
โป๏ธ :recycle: |
Performance | optimize , performance , speed , cache , perf |
โก :zap: |
Testing | test , testing , spec , coverage |
๐งช :test_tube: |
Security | security , vulnerability , auth , permission |
๐ :lock: |
Styling | style , format , lint , prettier |
๐ :lipstick: |
Dependencies | deps , dependency , package , upgrade |
๐ฆ :package: |
Configuration | config , configuration , settings , env |
โ๏ธ :gear: |
Architecture
The tool uses a clean strategy pattern with pluggable matchers:
pub type MatcherResult = ; // (emoji_code, formatted_message)
Current Matchers:
- SimpleMatcher: Keyword-based matching with 200+ keywords
- LLMMatcher: AI-powered matching (optional feature)
๐ ๏ธ CLI Options
๐งช Development
Building
# Debug build
# Release build
Testing
# Run all tests
# Run with output
# Run specific test module
Running
# Development
# With features
# Dry run
Project Structure
src/
โโโ main.rs # CLI application entry point
โโโ lib.rs # Library exports and integration tests
โโโ commit.rs # Git commit operations
โโโ emoji.rs # Emoji lookup and mapping
โโโ matcher/
โโโ mod.rs # Matcher trait and factory
โโโ simple.rs # Keyword-based matcher
โโโ llm.rs # LLM-based matcher (feature gated)
tests/
โโโ integration_tests.rs # Full workflow integration tests
fixtures/
โโโ gitmojis.json # Official gitmoji data (69 emojis)
โโโ keyword_map.json # Keyword to emoji mappings (200+ keywords)
๐ง Features & Configuration
Optional Features
[]
= []
= ["reqwest", "tokio", "dotenvy"]
To enable LLM support:
Environment Variables
# For LLM feature
๐ Quality Metrics
- Test Coverage: 65 tests (56 unit + 9 integration)
- Performance: < 100ms for typical operations
- Reliability: Comprehensive error handling and edge case coverage
- Compatibility: Works with all major terminals and Git workflows
๐ค Contributing
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Ensure all tests pass:
cargo test
- Submit a pull request
Code Style
- Use
cargo fmt
for formatting - Use
cargo clippy
for linting - Follow Rust 2024 edition standards
- Add tests for new functionality
๐ License
This project is licensed under the MIT License. See the LICENSE file for details.
๐ Acknowledgments
- Gitmoji for the comprehensive emoji standard
- The Rust community for excellent tooling and libraries
- Contributors and users who provide feedback and improvements