Thank you for investing your time in contributing to our project! We welcome feedback, bug reports, and pull requests!
Our development branch is main. When submitting pull requests, please adhere to the following guidelines:
- Add tests for any new features and bug fixes.
- Put a reasonable amount of comments into the code.
- Fork commit-check on your GitHub user account.
- Create a branch from
main, make your changes on the new branch, and then create a PR against themainbranch of the commit-check repository. - Separate unrelated changes into multiple pull requests for better review and management.
By contributing any code or documentation to this repository (by raising pull requests or otherwise), you explicitly agree to the License Agreement.
Commit-check validates Git commit metadata using a pipeline of configurable validators. The key flow is:
CLI args / Env vars / TOML file
│
▼
ConfigMerger ← Merges all config sources (priority: CLI > Env > TOML > Defaults)
│
▼
RuleBuilder ← Builds ValidationRule objects from merged config + rules catalog
│
▼
ValidationEngine ← Iterates over rules, picks the right validator for each
│
▼
BaseValidator subclasses ← Each validator performs one focused check
│
▼
Exit code 0/1
commit_check/
├── __init__.py # Package constants: DEFAULT_COMMIT_TYPES, DEFAULT_BRANCH_TYPES, DEFAULT_BOOLEAN_RULES
├── main.py # CLI entry point, argument parsing, StdinReader
├── config.py # TOML file loading (uses tomllib on Python 3.11+, tomli on older)
├── config_merger.py # ConfigMerger: merges CLI → Env → TOML → Defaults
├── rule_builder.py # RuleBuilder: creates ValidationRule objects from config + catalog
├── rules_catalog.py # Catalog of all rules (COMMIT_RULES, BRANCH_RULES)
├── engine.py # ValidationEngine, BaseValidator ABC, ValidationContext, ValidationResult
├── imperatives.py # ~258 English imperative verbs for subject validation
└── util.py # Git operations, output formatting (_print_failure)
BaseValidator (ABC)
├── CommitMessageValidator # Full message: conventional commits format
├── SubjectValidator (ABC)
│ ├── SubjectCapitalizationValidator # First letter must be uppercase
│ ├── SubjectImperativeValidator # Subject must start with imperative verb
│ └── SubjectLengthValidator # Subject length min/max
├── AuthorValidator # Author name and email format
├── BranchValidator # Branch naming conventions
├── MergeBaseValidator # Merge base / rebase target
├── SignoffValidator # Signed-off-by trailer presence
├── BodyValidator # Commit body presence
└── CommitTypeValidator # Handles merge/revert/fixup/wip/empty commits
| Priority | Source | Example |
|---|---|---|
| 1 (highest) | CLI arguments | --subject-max-length=72 |
| 2 | Environment variables | CCHK_SUBJECT_MAX_LENGTH=72 |
| 3 | TOML config files | cchk.toml, .github/cchk.toml, etc. |
| 4 (lowest) | Built-in defaults | defined in commit_check/__init__.py |
- Python 3.10 or newer
noxfor running build sessions:pip install nox
git clone https://github.com/commit-check/commit-check.git
cd commit-check
pip install -e ".[test]"# Fastest: run pytest directly
pytest tests/ -v
# With coverage report
nox -s coverage# Run all pre-commit hooks (ruff, mypy, codespell, etc.)
nox -s lint
# Or install hooks for automatic checks on every commit
pre-commit install# One-time build
nox -s docs
# Live preview with auto-reload
nox -s docs-livepre-commit try-repo ./../commit-check/ check-message --verbose --hook-stage commit-msg --commit-msg-filename .git/COMMIT_EDITMSGpython3 -m pip install --upgrade pip
pip install -e ./../commit-check/
commit-check -m- repo: https://github.com/commit-check/commit-check
rev: the tag or revision # update it to test commit hash
hooks:
- id: check-message
- id: check-branch
- id: check-author-emailWe appreciate your contributions to make Commit Check even better!