Skip to content

A Rust-based Git plugin that generates Git Flow–style commit messages from your staged diff using a local llama.cpp model.

License

Notifications You must be signed in to change notification settings

zh30/git-commit-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Git Commit Analyzer

中文 · Français · Español

Git Commit Analyzer is a Rust-based Git plugin that generates Git Flow–style commit messages from your staged diff using a local llama.cpp model. The CLI summarises large diffs, validates model output, and falls back to deterministic messages when needed.

Key Features

  • Local inference: Uses llama_cpp_sys_2 to run GGUF models without any remote API calls.
  • Smart diff summarisation: Large lockfiles and generated assets are reduced to concise summaries before prompting.
  • Git Flow enforcement: Ensures responses match <type>(<scope>): <subject> and retries/falls back when they don't.
  • Interactive CLI: Review, edit, or cancel the generated commit message.
  • Multi-language prompts: English (default) and Simplified Chinese.
  • Multi-platform support: Pre-built binaries for macOS (Intel & Apple Silicon).

Requirements

  • Git 2.30+
  • A local GGUF model (the CLI can download the default unsloth/gemma-3-270m-it-GGUF)

Installation

Homebrew (Recommended) - Fast Binary Installation

macOS users can install via Homebrew with pre-built binaries (no Rust compilation required):

brew tap zh30/tap
brew install git-ca

This installs a pre-built binary for your platform:

  • macOS: Apple Silicon (M1/M2/M3/M4) and Intel (x86_64)

No Rust toolchain or compilation needed! The binary is automatically downloaded from GitHub Releases.

Note: Linux builds are temporarily disabled due to compilation issues. Windows builds are available via GitHub Releases but not distributed via Homebrew.

Manual Installation

Download the appropriate binary for your platform from Releases:

# macOS (Apple Silicon)
curl -L -o git-ca.tar.gz https://github.com/zh30/git-commit-analyzer/releases/download/v1.1.2/git-ca-1.1.2-apple-darwin-arm64.tar.gz
tar -xzf git-ca.tar.gz
sudo mv git-ca /usr/local/bin/
chmod +x /usr/local/bin/git-ca

Note: Linux builds are temporarily disabled. Windows builds are available via GitHub Releases.

Build from Source

If you prefer to build from source:

git clone https://github.com/zh30/git-commit-analyzer.git
cd git-commit-analyzer
cargo build --release
sudo cp target/release/git-ca /usr/local/bin/

One-Line Bootstrap Script

bash -c "$(curl -fsSL https://sh.zhanghe.dev/install-git-ca.sh)"

First-Time Setup

On first run the CLI will:

  1. Scan for models in common directories:

    • ./models (project directory)
    • ~/.cache/git-ca/models (Linux/macOS)
    • ~/.local/share/git-ca/models (Linux alt)
    • ~/Library/Application Support/git-ca/models (macOS)
  2. Download default model automatically if none found:

    • Downloads unsloth/gemma-3-270m-it-GGUF from Hugging Face
    • Stores it in ~/.cache/git-ca/models/
  3. Prompt for confirmation if multiple models are found:

    git ca model  # Interactive model selector

Usage

git add <files>
git ca

For each invocation:

  1. The staged diff is summarised (lockfiles and large assets are listed but not inlined).
  2. The llama.cpp model generates a commit message.
  3. Invalid output triggers a stricter retry; if still invalid, a deterministic fallback is offered.
  4. Choose to use, edit, or cancel the message.

Configuration Commands

  • git ca model — Interactive model selector
  • git ca language — Choose English or Simplified Chinese prompts
  • git ca doctor — Test model loading and inference
  • git ca --version — Display version information

Development

cargo fmt
cargo clippy -- -D warnings
cargo test
cargo run -- git ca      # try against staged changes

Key modules:

  • src/main.rs — CLI orchestration, diff summariser, fallback generator.
  • src/llama.rs — llama.cpp session management.

Release Process

Fully automated release via GitHub Actions:

  1. Push a version tag: git tag v1.1.2 && git push origin v1.1.2
  2. GitHub Actions automatically:
    • Builds binaries for macOS (Intel & Apple Silicon)
    • Creates GitHub Release with changelog
    • Generates SHA256 checksums
    • Automatically updates Homebrew formula with bottle checksums
    • Pushes updates to homebrew-tap repository
  3. Users can immediately install with: brew install git-ca

Note: Linux builds are temporarily disabled due to compilation issues. Windows builds are available via GitHub Releases but not distributed via Homebrew.

See DEPLOY.md for complete release documentation.

Supported Platforms

  • macOS: ✅ Apple Silicon (arm64) and Intel (x86_64) - Pre-built binaries via Homebrew
  • Linux: ❌ Temporarily disabled (compilation issues)
  • Windows: ⚠️ Available via GitHub Releases (not Homebrew)

Contributing

Pull requests are welcome. Please include:

  • cargo fmt / cargo clippy -- -D warnings / cargo test outputs,
  • Updates to documentation (README*.md, AGENTS.md, DEPLOY.md) when behaviour changes,
  • A short description of manual git ca verification if applicable.

License

Released under the MIT License. See LICENSE for details.

Acknowledgments

  • The Rust community for providing excellent libraries and tools
  • llama.cpp team for the efficient local inference engine

About

A Rust-based Git plugin that generates Git Flow–style commit messages from your staged diff using a local llama.cpp model.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 2

  •  
  •