CoCoCheck¶
CoCoCheck checks commit messages against the
Conventional Commits specification. It runs on the command
line, as a commit-msg hook, or in CI, and is distributed as a single binary without runtime
dependencies. For each commit that fails a check, CoCoCheck names the rule and marks the relevant
part of the message:
Commit 3/3 b8cb601 "feat(API): add a timeout" failed:
error[scope_case]: Scope 'API' must be lowercase.
|
1 | feat(API): add a timeout
| ^^^
CoCoCheck finished checking 3 commits.
1 commit failed the checks.
Early development
CoCoCheck is in early development. The command-line interface and the configuration format may change in incompatible ways before version 1.0.
Features¶
- Prebuilt binaries for Linux, macOS, and Windows. Node.js, Python, or a Rust toolchain are not required.
- 16 rules for the header, the body, and the footers. Each rule can be disabled, or its
severity set to
errororwarning. - No configuration file is required. Merge, revert, and fixup commits created by Git are ignored by default.
- Text output for the terminal, and JSON output for other tools.
Installation¶
Prebuilt binaries are attached to every release. To install the latest release:
base=https://github.com/coco-tools/cococheck/releases/latest/download
mkdir -p ~/.local/bin
curl -sSfL "$base/cococheck-$(uname -m)-unknown-linux-musl.tar.gz" \
| tar -xz -C ~/.local/bin cococheck
This installs cococheck to ~/.local/bin. Make sure that this directory is in your PATH.
base=https://github.com/coco-tools/cococheck/releases/latest/download
arch=$(uname -m | sed s/arm64/aarch64/)
mkdir -p ~/.local/bin
curl -sSfL "$base/cococheck-$arch-apple-darwin.tar.gz" \
| tar -xz -C ~/.local/bin cococheck
This installs cococheck to ~/.local/bin. Make sure that this directory is in your PATH.
$base = "https://github.com/coco-tools/cococheck/releases/latest/download"
Invoke-WebRequest "$base/cococheck-x86_64-pc-windows-msvc.zip" `
-OutFile "$env:TEMP\cococheck.zip"
Expand-Archive "$env:TEMP\cococheck.zip" `
"$env:LOCALAPPDATA\Programs\cococheck" -Force
This installs cococheck.exe to %LOCALAPPDATA%\Programs\cococheck. Make sure that this
directory is in your PATH.
Alternatively, install CoCoCheck with Cargo: cargo binstall cococheck downloads the prebuilt
binary, and cargo install cococheck builds it from source. For further options, see
Installation.
Quick start¶
-
Check the commits of the repository. Without arguments, CoCoCheck checks all commits up to
HEAD. A revision range likemain..limits the check to the commits of the current branch, and--from-latest-tagto the commits since the latest tag: -
To check each commit message when the commit is created, add a
commit-msghook. Create the file.git/hooks/commit-msgwith the following content, and make it executable withchmod +x .git/hooks/commit-msg:For hook managers like pre-commit, Lefthook, and husky, see Git hooks.
-
To check the commits of every pull request before it is merged, add the CoCoCheck action to a GitHub Actions workflow:
on: pull_request: permissions: contents: read jobs: cococheck: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 with: # Fetch the full history, so that the commits to check can be found. fetch-depth: 0 - uses: coco-tools/cococheck-action@v1Using CoCoCheck in CI also covers checking pushed commits, the options of the action, and other CI systems.
All settings are optional. To adapt the rules to the conventions of your project, add a
cococheck.yml file to the root of the repository. For details, see
Configuration.