A git commit-msg hook that enforces and auto-corrects Conventional Commits format.
type(scope): description
Supported types: feat, fix, chore, docs, style, refactor, test, ci, perf, build
- Lowercases the type prefix (
FEAT:→feat:) - Lowercases the first character of the description
- Trims leading/trailing whitespace and collapses multiple spaces
- Auto-corrects missing colons (
feat add login→feat: add login) - Enforces max subject length (default: 72 chars)
- Rejects unknown types and empty descriptions
# Install into the current repo
./install.sh
# Install into another repo
./install.sh /path/to/repoEdit commit-normalize.config.json in the repo root:
{
"types": ["feat", "fix", "chore", "docs", "style", "refactor", "test", "ci", "perf", "build"],
"maxSubjectLength": 72,
"requireScope": false,
"autoCorrect": true
}# Normalize all commits from root
./normalize.sh
# Normalize commits after a specific ref
./normalize.sh mainWarning: This rewrites git history. Only use on unpublished branches.
bash tests/test_commit_msg.sh