Skip to content

Commit 8ac62e8

Browse files
authored
docs: bring the site in step with v2.18.3 (#50)
<!-- ccr-projects-attribution: {"github_login":"shenxianpeng"} --> _Requested by **Xianpeng** · [project thread](https://claude.ai/code/project/chan_017XBs7zagX2sxAJ7SUwfyPW?thread=cmsg_017XBs7zagX2sxAJ7SUwfyPWGW1J6v52rdKGW6MGk2bt6z)_ Before: the site described 2.18.2, while 2.18.3 is what `pip install commit-check` gets. The pre-commit snippets installed 2.18.2 and the changelog stopped there. `--fix` and the warning for a misspelt setting were documented nowhere. The GitLab, Bitbucket and Azure jobs piped the branch name into `--branch`, a workaround 2.18.3 no longer needs. The pre-commit guide's hook table had no `check-tag` or `check-files`, although the README sends readers there for them. After: the site describes 2.18.3. - **Site in step with v2.18.3**, per AGENTS.md: the four pre-commit pins move from v2.18.2 to v2.18.3. The changelog gains the v2.18.3 entry, dated 2026-10-07 (the GitHub release and the PyPI upload), with a Highlights row because the release adds user-visible behaviour. - **GitLab CI, Bitbucket and Azure Pipelines:** each job runs a plain `commit-check --branch`, which reads the CI's own variables since commit-check/commit-check#600. A note keeps the piped form for 2.18.2 and older, which pinned installs still need. - **Command-line recipes:** a "Fixing a message in place" section for `--fix` (commit-check/commit-check#594), and a paragraph on how `--branch` names the branch on a detached checkout. - **Pre-commit hook:** `args: [--fix]` on `check-message`. The hook table adds `check-files` and `check-tag`, pre-push hooks since 2.16.0, and gives `check-message` its full range, CC001–CC016 since 2.18.0; the App guide had the same stale range. A note says pre-commit runs no hook for a push that creates a ref without new commits, so a tag pushed on its own after its commit is never checked. - **Configuration:** "Settings nothing reads", for the warning from commit-check/commit-check#593. How: every sample is a transcript from 2.18.3. I ran `--fix` on a message file, on stdin, with `--rev` and with `--dry-run`, and ran the `check-message` hook with `args: [--fix]` through pre-commit at `rev: v2.18.3`; it recorded `Fix: add streaming support` as `fix: add streaming support`. For the branch step, a plain `commit-check --branch` on a detached checkout passed a valid name and failed `bad_branch_name` under each CI's variables, including both forms of Azure's source branch. For the push hooks, with pre-commit 4.6.2 at `rev: v2.18.3`: `check-files` rejected a 4 KB file over `max_size = "1KB"`, `check-tag` rejected `release-2.0` pushed with its commit, and `release-1.0`, pushed alone on a commit the remote already had, ran no hook at all (pre-commit skips a new ref that carries no commits the remote lacks). Checks: `python -m pytest tests/ -q` passes against the released 2.18.3 (10 passed); before the pin change, `test_pinned_revisions_match_the_released_version` failed as expected. `mkdocs build --strict` passes with `SOCIAL_CARDS=false`, and every new in-page link resolves to an anchor in the built site. The YAML snippets parse. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_013rE6bouKaJvsRyKA4tjqCb ---------
1 parent ac8e2e5 commit 8ac62e8

6 files changed

Lines changed: 143 additions & 19 deletions

File tree

‎docs/changelog.md‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ below and to the page that documents the feature properly.
1111

1212
| Version | What changed | Documented in |
1313
|---|---|---|
14+
| [2.18.3](#v2183) | `--fix` corrects a message in place; `--branch` reads GitLab, Bitbucket, Azure and Jenkins variables | [Fixing a message in place](example.md#fixing-a-message-in-place) · [Other CI](guides/other-ci.md) |
1415
| [2.18.0](#v2180) | AI disclosure policy: three rules, and the correction written for you | [Policy guides](guides/policies.md#asking-for-disclosure-instead) · [CC014](rules.md#cc014) |
1516
| [2.17.0](#v2170) | Concrete corrections for mechanical slips; a `warn` level per rule | [Reading the JSON](example.md#reading-the-json) · [Report without enforcing](configuration.md#report-a-rule-without-enforcing-it) |
1617
| [2.16.0](#v2160) | Tag name validation, and file size, path and pattern policies | [CC401](rules.md#cc401) · [CC302–CC304](rules.md#push-rules) |
@@ -29,6 +30,40 @@ below and to the page that documents the feature properly.
2930
| [2.5.0](#v250) | Organization-wide config with `inherit_from` | [Across an organization](guides/organization.md) |
3031
| [2.0.0](#v200) | Configuration moved from YAML to TOML — breaking | [Migrating from v1](migration.md) |
3132

33+
## v2.18.3 (2026-10-07) { #v2183 }
34+
35+
### Added
36+
37+
* **`--fix` corrects a commit message in place** — when every message check
38+
the commit failed has a mechanical fix, the ones `--format json` reports in
39+
`fix`, the message file is rewritten and the check passes, so
40+
`Fix: add streaming support` is recorded as `fix: add streaming support`.
41+
Anything that takes a judgment, such as a subject with no type at all,
42+
leaves the file as it was and is rejected as before. It needs a message
43+
file, so stdin and `--rev` are a usage error, and `--dry-run` rewrites
44+
nothing. With pre-commit it is `args: [--fix]` on `check-message`.
45+
See PR [#594](https://github.com/commit-check/commit-check/pull/594) and
46+
[Fixing a message in place](example.md#fixing-a-message-in-place).
47+
48+
* **`--branch` reads the branch from GitLab, Bitbucket, Azure and Jenkins** —
49+
on a detached checkout git names no branch, and only GitHub's variables
50+
were read, so elsewhere the name became `HEAD`, which is always allowed, and
51+
every branch passed. Each CI's own variables are now read, a merge or pull
52+
request's source branch first, and Jenkins' only inside a Jenkins build that
53+
is not a tag build. A pipeline that runs `--branch` on a long-lived branch
54+
such as `develop` now has that name judged; `allow_branch_names` can allow
55+
it.
56+
See PR [#600](https://github.com/commit-check/commit-check/pull/600) and
57+
[GitLab CI, Bitbucket and Azure Pipelines](guides/other-ci.md).
58+
59+
* **A setting nothing reads is named** — a misspelt key in `cchk.toml` was
60+
ignored in silence, and its rule stayed at the default. Each one is now
61+
reported on stderr with the closest real name, as in `⚠ unknown setting
62+
[commit] subject_max_lenght is ignored; did you mean subject_max_length?`.
63+
The exit code and the JSON do not change.
64+
See PR [#593](https://github.com/commit-check/commit-check/pull/593) and
65+
[Settings nothing reads](configuration.md#settings-nothing-reads).
66+
3267
## v2.18.2 (2026-09-28) { #v2182 }
3368

3469
### Fixed

‎docs/configuration.md‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,28 @@ $ commit-check --config path/to/cchk.toml --message
6565
PyCharm and IntelliJ offer completion, validation and inline documentation
6666
for `cchk.toml` with nothing to configure.
6767

68+
### Settings nothing reads
69+
70+
A key that no check reads, usually a misspelling, leaves its rule at the
71+
default. Commit Check names each one on stderr, with the closest real name:
72+
73+
```toml title="cchk.toml"
74+
[commit]
75+
subject_max_lenght = 50
76+
```
77+
78+
```console
79+
$ echo "feat: add streaming support" | commit-check -m
80+
⚠ unknown setting [commit] subject_max_lenght is ignored; did you mean subject_max_length?
81+
```
82+
83+
It is a warning, not an error: the exit code and the JSON on stdout do not
84+
change. The top-level `warn` list and the GitHub App's
85+
[`[jira]`](guides/github-app.md#jira-ticket-references) and
86+
[`[pull_request]`](#pull-requests-every-commit-or-the-squash-message) sections
87+
are read elsewhere and are not reported. The Python API and the MCP server
88+
load the file themselves and do not report it either.
89+
6890
## Inheriting a shared config
6991

7092
An organization can keep one base policy and have every repository build on it.
@@ -239,7 +261,7 @@ Used from a hook definition, with no config file anywhere in the repository:
239261
```yaml title=".pre-commit-config.yaml"
240262
repos:
241263
- repo: https://github.com/commit-check/commit-check
242-
rev: v2.18.2
264+
rev: v2.18.3
243265
hooks:
244266
- id: check-message
245267
args:

‎docs/example.md‎

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,27 @@ EOF
8181
$ commit-check -m /tmp/msg.txt
8282
```
8383

84+
### Fixing a message in place
85+
86+
`--fix` corrects the message instead of only rejecting it. When every check
87+
the message failed has a mechanical fix, the corrections that
88+
[`--format json` reports in `fix`](#reading-the-json), it rewrites the message
89+
file and the check passes:
90+
91+
```console
92+
$ printf 'Fix: add streaming support\n' > msg.txt
93+
$ commit-check -m --fix msg.txt
94+
✎ fixed the commit message: CC001 message
95+
$ cat msg.txt
96+
fix: add streaming support
97+
```
98+
99+
A failure that takes a judgment, such as `updated the parser`, which has no
100+
type at all, leaves the file as it was and fails as before. `--fix` needs a
101+
message file to rewrite, so with stdin or `--rev` it is a usage error, and
102+
`--dry-run` rewrites nothing. In the `commit-msg` hook it is one argument:
103+
see [Fixing the message instead of rejecting it](guides/pre-commit.md#fixing-the-message-instead-of-rejecting-it).
104+
84105
## Checking the branch
85106

86107
```console
@@ -97,6 +118,13 @@ feature/role-caching
97118
release/v1.2.0
98119
```
99120

121+
On a detached HEAD, which is how most CI systems check out a commit, git has
122+
no branch to report, so the name comes from the CI's own variables: GitHub
123+
Actions, GitLab CI, Bitbucket Pipelines, Azure Pipelines, and Jenkins
124+
multibranch inside a Jenkins build. A merge or pull request's source branch is
125+
read first. With none of these set, the name is `HEAD`. The variables other
126+
than GitHub's are read from 2.18.3 on.
127+
100128
## Checking the committer
101129

102130
```console
@@ -131,7 +159,7 @@ pushed:
131159
```yaml title=".pre-commit-config.yaml"
132160
repos:
133161
- repo: https://github.com/commit-check/commit-check
134-
rev: v2.18.2
162+
rev: v2.18.3
135163
hooks:
136164
- id: check-no-force-push
137165
stages: [pre-push]
@@ -302,7 +330,8 @@ $ echo "Fix: add streaming support" | commit-check -m --format json | jq '.check
302330
`fix` is empty whenever the correction takes a judgment — a subject with no
303331
type at all, one over the length limit, a verb that is not imperative — and
304332
`suggest` then keeps the rule's general advice. A tool can apply a non-empty
305-
`fix` as it stands; a person only ever needs `suggest`.
333+
`fix` as it stands, and [`--fix`](#fixing-a-message-in-place) does that to a
334+
message file; a person only ever needs `suggest`.
306335

307336
A rule listed under [`warn`](configuration.md#report-a-rule-without-enforcing-it)
308337
reports with `"status": "warn"` instead of `"fail"`. The top-level `status` is

‎docs/guides/github-app.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ way everywhere:
4747

4848
### Which rules
4949

50-
The App runs the commit message, author and branch rules — [CC001–CC013](../rules.md#commit-message-rules),
50+
The App runs the commit message, author and branch rules — [CC001–CC016](../rules.md#commit-message-rules),
5151
[CC101–CC102](../rules.md#author-rules) and [CC201–CC202](../rules.md#branch-rules) —
5252
with the commit's own branch as the branch under test. One thing it does not
5353
do: the push, file and tag rules ([CC301–CC304](../rules.md#push-rules),

‎docs/guides/other-ci.md‎

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ hook and the Action.
99
Two things are different from running it on your own machine, and each
1010
example below handles both:
1111

12-
- **The checkout is a detached HEAD.** git has no branch to report, so
13-
`commit-check --branch` would judge `HEAD`, which is always allowed, and
14-
pass whatever the branch is called. Pipe the branch name in from the CI's
15-
own variable instead: a value piped into `--branch` on its own is the name
16-
it checks.
12+
- **The checkout can be a detached HEAD**, as it is on GitLab and Azure, and
13+
then git has no branch to report. `commit-check --branch` reads the name
14+
from the CI's own variables instead, the merge or pull request's source
15+
branch first, so the jobs call it as is.
1716
- **A merge request has more than one commit.** `--rev` checks one commit, so
1817
the job loops over the commits the merge request adds, as in
1918
[Checking a range of commits](../example.md#checking-a-range-of-commits).
@@ -25,6 +24,19 @@ Each job runs on merge or pull requests only, because the variables it reads
2524
exist only there. Add `--author-name --author-email` to the `commit-check`
2625
call in the loop to check each commit's author as well.
2726

27+
!!! note "On 2.18.2 or older"
28+
29+
Releases before 2.18.3 read only GitHub's variables, so on a detached
30+
checkout `--branch` judges `HEAD`, which is always allowed, and passes
31+
whatever the branch is called. Pipe the name in instead: a value piped
32+
into `--branch` on its own is the name it checks.
33+
34+
```console
35+
$ echo "$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" | commit-check --branch # GitLab
36+
$ echo "$BITBUCKET_BRANCH" | commit-check --branch # Bitbucket
37+
$ echo "${SYSTEM_PULLREQUEST_SOURCEBRANCH#refs/heads/}" | commit-check --branch # Azure
38+
```
39+
2840
## GitLab CI
2941

3042
```yaml title=".gitlab-ci.yml"
@@ -36,7 +48,7 @@ commit-check:
3648
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
3749
script:
3850
- pip install commit-check
39-
- echo "$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" | commit-check --branch
51+
- commit-check --branch
4052
- |
4153
head="${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA:-$CI_COMMIT_SHA}"
4254
shas=$(git rev-list "$CI_MERGE_REQUEST_DIFF_BASE_SHA..$head") || exit 1
@@ -69,7 +81,7 @@ pipelines:
6981
depth: full
7082
script:
7183
- pip install commit-check
72-
- echo "$BITBUCKET_BRANCH" | commit-check --branch
84+
- commit-check --branch
7385
- |
7486
shas=$(git rev-list "$BITBUCKET_PR_DESTINATION_COMMIT..$BITBUCKET_COMMIT") || exit 1
7587
status=0
@@ -104,7 +116,7 @@ steps:
104116
versionSpec: "3.13"
105117
- script: pip install commit-check
106118
displayName: Install Commit Check
107-
- script: echo "${SYSTEM_PULLREQUEST_SOURCEBRANCH#refs/heads/}" | commit-check --branch
119+
- script: commit-check --branch
108120
displayName: Check the branch name
109121
- script: |
110122
shas=$(git rev-list HEAD^1..HEAD^2) || exit 1
@@ -123,9 +135,9 @@ steps:
123135
- A pull request build checks out a merge commit whose first parent is the
124136
target branch and second the pull request, so `HEAD^1..HEAD^2` is exactly
125137
the commits the pull request adds.
126-
- `System.PullRequest.SourceBranch` is `refs/heads/feature/x` in Azure Repos
127-
and `feature/x` for a GitHub repository; `#refs/heads/` strips the prefix
128-
where there is one.
138+
- The branch name comes from `System.PullRequest.SourceBranch`, which is
139+
`refs/heads/feature/x` in Azure Repos and `feature/x` for a GitHub
140+
repository. Commit Check drops the `refs/heads/` prefix itself.
129141
- In Azure Repos the `pr:` section is ignored. Pull request builds come from a
130142
[build validation branch policy](https://learn.microsoft.com/en-us/azure/devops/repos/git/branch-policies#set-build-validation)
131143
on the target branch, and `System.PullRequest.SourceBranch` is only set for

‎docs/guides/pre-commit.md‎

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Add Commit Check to `.pre-commit-config.yaml`:
88
```yaml title=".pre-commit-config.yaml"
99
repos:
1010
- repo: https://github.com/commit-check/commit-check
11-
rev: v2.18.2
11+
rev: v2.18.3
1212
hooks:
1313
- id: check-message
1414
- id: check-branch
@@ -36,26 +36,32 @@ That is it. The next malformed commit message is rejected before it exists.
3636

3737
| Hook ID | Stage | Rules |
3838
|---|---|---|
39-
| `check-message` | `commit-msg` | [CC001–CC013](../rules.md#commit-message-rules) |
39+
| `check-message` | `commit-msg` | [CC001–CC016](../rules.md#commit-message-rules) |
4040
| `check-branch` | `pre-commit` | [CC201–CC202](../rules.md#branch-rules) |
4141
| `check-author-name` | `pre-commit` | [CC101](../rules.md#cc101) |
4242
| `check-author-email` | `pre-commit` | [CC102](../rules.md#cc102) |
4343
| `check-no-force-push` | `pre-push` | [CC301](../rules.md#cc301) |
44+
| `check-files` | `pre-push` | [CC302–CC304](../rules.md#push-rules) |
45+
| `check-tag` | `pre-push` | [CC401](../rules.md#cc401) |
4446

45-
`check-no-force-push` also needs its own install:
47+
The three `pre-push` hooks need their own install too:
4648

4749
```console
4850
$ pre-commit install --hook-type pre-push
4951
```
5052

53+
pre-commit runs no hook for a push that creates a ref without carrying new
54+
commits. So a new tag pushed on its own, when the commit it points at is
55+
already on the remote, is never seen by `check-tag`.
56+
5157
## Configuring without a TOML file
5258

5359
Options can be passed as hook arguments, which keeps everything in one file:
5460

5561
```yaml title=".pre-commit-config.yaml"
5662
repos:
5763
- repo: https://github.com/commit-check/commit-check
58-
rev: v2.18.2
64+
rev: v2.18.3
5965
hooks:
6066
- id: check-message
6167
args:
@@ -68,6 +74,26 @@ A `cchk.toml` is usually the better choice once you have more than a couple of
6874
options, because CI and the CLI read it too. See
6975
[Configuration](../configuration.md) for the precedence rules.
7076

77+
## Fixing the message instead of rejecting it
78+
79+
Give `check-message` the `--fix` argument and it corrects a message whose
80+
every failure has a mechanical fix, such as a type written `Fix` or a missing
81+
colon, and lets the commit through:
82+
83+
```yaml title=".pre-commit-config.yaml"
84+
repos:
85+
- repo: https://github.com/commit-check/commit-check
86+
rev: v2.18.3
87+
hooks:
88+
- id: check-message
89+
args: [--fix]
90+
```
91+
92+
With that, `git commit -m "Fix: add streaming support"` records
93+
`fix: add streaming support`. A message that needs a judgment, such as one
94+
with no type at all, is rejected as before. More in
95+
[Fixing a message in place](../example.md#fixing-a-message-in-place).
96+
7197
## Skipping a hook
7298

7399
Occasionally you need to get a commit through — a mid-rebase fixup, an

0 commit comments

Comments
 (0)