Validate Co-authored-by trailers in commit messages.
Project description
coauthorcheck
Lightweight command-line validation for Co-authored-by commit trailers.
Table of Contents
Usage
You can use coauthorcheck in one of these three ways:
- as a
pre-commitcommit-msghook for immediate local feedback - in GitHub Actions to validate branch or pull request commits before merge
- directly from CLI
pre-commit
Add this to .pre-commit-config.yaml:
repos:
- repo: https://github.com/simoncraf/coauthorcheck
rev: v0.2.1
hooks:
- id: coauthorcheck
stages: [commit-msg]
Then install the hook:
pre-commit install --hook-type commit-msg
This is required because coauthorcheck validates the final commit message file, and commit-msg is the Git hook that receives that file.
GitHub Actions
Validate commits introduced by branch pushes:
name: Validate Co-authored-by trailers
on:
push:
branches:
- "feature/**"
- "feat/**"
jobs:
validate-commits:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install coauthorcheck
run: pip install coauthorcheck==0.2.1
- name: Validate branch commits
run: coauthorcheck "origin/main..HEAD"
Validate commits introduced by a pull request:
name: Validate Co-authored-by trailers on PR
on:
pull_request:
branches:
- main
jobs:
validate-commits:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install coauthorcheck
run: pip install coauthorcheck==0.2.1
- name: Validate PR commits
run: coauthorcheck "origin/${{ github.base_ref }}..HEAD"
See docs/integrations.md for local hooks, JSON output, PR comments, and more workflow examples.
CLI
coauthorcheck .git/COMMIT_EDITMSG
coauthorcheck HEAD
coauthorcheck HEAD~5..HEAD
coauthorcheck main..HEAD
coauthorcheck origin/main..HEAD
coauthorcheck --file .git/COMMIT_EDITMSG
coauthorcheck --commit HEAD
coauthorcheck --range HEAD~5..HEAD
Positional input is auto-detected in this order:
- values containing
..or...are treated as commit ranges - existing paths are treated as commit message files
- everything else is treated as a commit ref
Use the explicit flags when you want fully unambiguous scripting.
Check the installed CLI:
coauthorcheck --help
Installation
Install from PyPI:
pip install coauthorcheck
Or with uv:
uv tool install coauthorcheck
Or with pipx:
pipx install coauthorcheck
After installation, run:
coauthorcheck --help
Common CLI Workflows
Validate the commit message currently being edited:
coauthorcheck .git/COMMIT_EDITMSG
Validate only the commits introduced by your current branch compared with main:
coauthorcheck main..HEAD
Validate only the commits introduced by your branch compared with the remote default branch:
coauthorcheck origin/main..HEAD
Validate the last few commits on the current branch:
coauthorcheck HEAD~3..HEAD
Configuration
coauthorcheck supports repository-local configuration from either:
pyproject.tomlunder[tool.coauthorcheck].coauthorcheck.toml
Configuration is resolved in this order:
--config <path>- nearest
.coauthorcheck.toml - nearest
pyproject.tomlwith[tool.coauthorcheck] - built-in defaults
When config files are auto-discovered, coauthorcheck searches upward from the current working directory. This means running the tool from a nested folder in the repo still finds the repo-level config.
Example using pyproject.toml:
[tool.coauthorcheck.rules]
single_word_name = false
github_handle = true
incorrect_casing = true
invalid_format = true
malformed_email = true
missing_email = true
missing_name = true
Example using .coauthorcheck.toml:
[rules]
single_word_name = false
github_handle = false
incorrect_casing = true
invalid_format = true
malformed_email = true
missing_email = true
missing_name = true
Use an explicit config file with:
coauthorcheck --config .coauthorcheck.toml main..HEAD
Unknown rule names or non-boolean values are treated as configuration errors.
See docs/rules.md for a detailed explanation of each rule.
See docs/integrations.md for pre-commit, GitHub Actions, JSON output, and PR comment examples.
Use coauthorcheck --format json ... for machine-readable output in CI and automation.
Development
Set up the local environment:
uv sync
Run the CLI from the project environment:
uv run coauthorcheck --help
Run the tool from another repository by changing into that repository first and then invoking the executable from this project:
cd /path/to/other-repo
/path/to/coauthorcheck/.venv/Scripts/coauthorcheck.exe main..HEAD
In Git Bash, use /c/... style paths:
/path/to/coauthorcheck/.venv/Scripts/coauthorcheck.exe main..HEAD
Run the test suite:
uv run pytest
Run the linter:
uv run ruff check .
Project details
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