Rust library and CLI to generate Conventional Commit messages using Ollama (default model: mistral).
- Ensure Ollama is running locally and the model is available.
- Build from source:
cargo install --path ollacommit-cliollacommit --model mistral --include-diff --dry-run
ollacommit --no-edit # run git commit -F <msg> without opening editorFlags:
--model <name>: Ollama model (defaultmistral)--base-url <url>: Ollama base URL (defaulthttp://localhost:11434)--include-diff: Include unified diff in prompt--dry-run: Print message only--no-edit: Usegit commit -Fwithout-e--message-only: Print message only (alias for piping/integration)--max-prompt-chars <n>: Limit prompt size (default 20000)
Add to ~/.config/lazygit/config.yml:
customCommands:
- key: 'C'
context: 'files'
description: 'OllaCommit (AI)'
prompts:
- type: 'input'
title: 'Model'
initialValue: 'mistral'
command: 'ollacommit --model {{index .PromptResponses 0}} --include-diff --no-edit'Alternatively, to just print to LazyGit's commit view:
command: 'ollacommit --message-only --include-diff'See ollacommit-core crate: generate_commit_message(path, opts) returns a parsed CommitMessage.
cargo testIntegration tests mock the Ollama HTTP endpoint and run in a temporary git repo.