gitru
Git Commit Message Validation Tool
gitru is a lightweight, configurable Git commit message validation tool designed to enforce Conventional Commits standards across development teams.
Installation
Method 1: (Recommended)
With Rust toolchain installed:
Method 2:
Download pre-built binary:
- Get latest release for your OS
- Add to system PATH
- Set executable permissions:
Usage
Install hook and initialize configuration:
Command breakdown:
ii=install(sets up git hook) +init(creates config template)- Execute separately:
gitru install commit-msgandgitru init commit-msg
For more options:
Workflow
After installation:
- Git hook installed to
.git/hooks/commit-msg - Configuration template created at
.commit-msg-rule.toml
Customize validation rules by editing .commit-msg-rule.toml.
You can optionally modify, delete, or comment out the options that do not require validation.
configuration file example:
# The Conventional Commits
#
# ╔═════════════════════════════════════════════════╗
# ║ COMMIT FORMAT TEMPLATE ║
# ╠═════════════════════════════════════════════════╣
# ║ type(optional scope): subject ║
# ║ ║
# ║ [optional body] ║
# ║ ║
# ║ [optional footer] ║
# ║ - BREAKING CHANGE: xxxxx ║
# ║ - Closes #issue ║
# ╚═════════════════════════════════════════════════╝
#
[]
= "1.0.0"
= true
= [
"--no-verify",
"SKIP",
]
[]
[]
= [
"feat", # New feature
"fix", # Bug fix
"docs", # Documentation
"style", # Code style
"refactor", # Code refactor
"test", # Test related
"chore", # Maintenance
]
[]
= false
= [
"core",
"cli",
"ui",
"docs",
"test",
]
[]
= 1
= true # Forbid ending with a period
= 2 # Default min_length is 2
= 72 # Default max_length is 72
[]
= false
= 1
= true
= 2
= 72
[]
= ["BREAKING CHANGE", "Closes", "Fixes", "Signed-off-by"]
= 1
= 2
= 72
= true
# Whether to enable spell checking for footer keywords
[]
# When enabled, and the commit contains only a header + body (no footer),
# the body will be checked to determine whether it is a misspelled footer keyword.
= true
# Similarity threshold. Default is 0.7.
# When the similarity score exceeds this threshold, the text is considered a misspelling.
= 0.7
Commit validation example:
Validation success Example:
Validation Failure Example:
(default config)
Skip Validation
There are three ways to skip validation:
- Add the
--no-verifyoption when committing from the command line. - Manually choose “skip validation” in your IDE’s commit interface.
- Write the keyword specified in the
skip_validation_wordsoption (from the configuration file) as the first line of the commit message. This will automatically skip validation.
Note: the keyword must appear alone on a single line.
This means the following commit message will pass directly without any validation:
--no-verify
feat: add new feature
Uninstall
remove commit-msg hook from .git/hooks directory:
gitru uninstall commit-msg
remove .commit-msg-rule.toml file manually .