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 (rejected) / 2 (config error)
commit_check/
├── __init__.py # Package constants: DEFAULT_COMMIT_TYPES, DEFAULT_BRANCH_TYPES, DEFAULT_BOOLEAN_RULES
├── main.py # CLI entry point, argument parsing, StdinReader
├── api.py # Public Python API (validate_message, validate_branch, ...) without a subprocess
├── ci.py # commit-check-ci: checks a whole merge or pull request on GitLab CI and Bitbucket Pipelines
├── config.py # TOML file loading (stdlib tomllib), inherit_from, deep_merge
├── 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, PUSH_RULES, FILES_RULES, TAG_RULES)
├── engine.py # ValidationEngine, BaseValidator ABC, ValidationContext, ValidationResult
├── fixes.py # Suggested fixes printed with a failure (header, case, WIP, sign-off, branch type)
├── ai_signatures.py # detect_ai_signatures / has_ai_signature for the ai_attribution rule
├── ai_signatures_data.py # Registry of known AI tool signatures (pure data)
├── ai_policy.py # The "disclose" policy: reads a message's AI signatures against the accepted trailers and names the corrected message
├── imperatives.py # IMPERATIVES / NON_IMPERATIVE_LOOKALIKES sets used by the -s stem test in CC003 (not an allow-list)
└── 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
├── TagValidator # Tag name pattern
├── FilesValidator # Committed file size, path pattern, path length
├── MergeBaseValidator # Merge base / rebase target
├── SignoffValidator # Signed-off-by trailer presence
├── BodyValidator # Commit body presence
├── ForcePushValidator # Non-fast-forward push detection
├── CommitTypeValidator # Handles merge/revert/fixup/wip/empty commits
└── AiAttributionValidator # AI tool signatures in the message
| 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.11 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 installThe user documentation lives in a separate repository and is served from
https://commit-check.com; this repository only carries README.md. There is no
docs build session here.
pre-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!