Opinionated conventional commit message linter with imperative mood detection
Project description
commit-guard
Opinionated conventional commit message linter with imperative mood detection.
Unlike regular expression only tools, commit-guard uses NLP (nltk POS tagging) to verify that commit descriptions start with an imperative verb.
Installation
uv tool install -e .
commit-guard
During development:
uv run commit-guard
Usage
# check HEAD
commit-guard
# check specific commit
commit-guard abc1234
# check commit message file (for git hooks)
commit-guard --message-file .git/COMMIT_EDITMSG
# pipe message via stdin
echo "fix(auth): add token refresh" | commit-guard
Selecting checks
All checks run by default. Use --enable or --disable with
comma-separated values:
# only check subject format and imperative mood
commit-guard --enable subject,imperative
# skip body and signature checks
commit-guard --disable body,signed-off,signature
Available checks:
subject- Format matchestype(scope): description, valid type, lowercase start, no trailing period, max 72 charsimperative- First word is an imperative verb (for exampleaddnotadded)body- Body is present after a blank linesigned-off-Signed-off-by:trailer existssignature- Verify GPG or SSH signature
Checking a range of commits
# all non-merge commits between tags
git rev-list --no-merges v1.0..v2.0 | while read -r rev; do
commit-guard "$rev" || git log -1 --oneline "$rev"
done
# only subject checks on a PR range
git rev-list --no-merges origin/main..HEAD | while read -r rev; do
commit-guard "$rev" --enable subject,imperative
done
Imperative mood detection
commit-guard combines two strategies to detect non-imperative descriptions:
- A whitelist common commit verbs (
add,fix,remove, etc.) that pass immediately without NLP. - nltk POS tagging as a fallback — flags words tagged as past tense (
VBD), gerund (VBG), third person (VBZ), etc.
This catches common mistakes like added logging or fixes bug while
keeping false positives low.
Conventional commit format
type(scope): description
body
trailers
Supported types: feat, fix, docs, style, refactor, perf, test,
build, ci, chore, revert.
Scope is optional. Mark breaking changes with ! before
the colon.
License
GPLv2
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file git_commit_guard-0.4.0.tar.gz.
File metadata
- Download URL: git_commit_guard-0.4.0.tar.gz
- Upload date:
- Size: 22.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
908f7fb75b2e285a8f33902f25b982e28b5d495b9a9d46069524a03006e821ee
|
|
| MD5 |
dc4e40bf9264b7aceff3485aa1282fe2
|
|
| BLAKE2b-256 |
bcb59d513352679de009a03c681cc9915d3216834b0ec2ecc36aaca49f7968fe
|
File details
Details for the file git_commit_guard-0.4.0-py3-none-any.whl.
File metadata
- Download URL: git_commit_guard-0.4.0-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ceb27a376f7fc9f573402248438d9c5a0a8400c091a9e4658534022ced25e26a
|
|
| MD5 |
2a7cd287294d864b481719e1d1222480
|
|
| BLAKE2b-256 |
29a04d21f1954a73ef7919513ccc2358cf986f27f12e003223d7dbe17fafa1bf
|