diff --git a/docs/changelog.md b/docs/changelog.md index d51e41f..d98836f 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -11,6 +11,7 @@ page that documents it. | Version | What changed | Documented in | |---|---|---| +| [2.24.0](#v2240) | `body_max_line_length` limits the length of a body line (opt-in); the JSON lists settings that are not in force in `notices` | [CC018](rules.md#cc018) · [Reading the JSON](example.md#reading-the-json) | | [2.23.1](#v2231) | git's `Revert "..."` and `Reapply "..."` commits pass; `revert` is a default type again; several failures quote the message once | [CC001](rules.md#cc001) · [CC004](rules.md#cc004) · [CC007](rules.md#cc007) | | [2.23.0](#v2230) | `commit-check-ci` checks a whole merge or pull request in one GitLab CI job or Bitbucket Pipelines step | [GitLab CI, Bitbucket and Azure Pipelines](guides/other-ci.md) | | [2.22.0](#v2220) | `--pr-title` checks a pull or merge request title on any CI; the rebase check works in Bitbucket pull request steps and GitLab merged results pipelines | [GitLab CI, Bitbucket and Azure Pipelines](guides/other-ci.md#merge-request-title-and-description) · [CC202](rules.md#cc202) | @@ -45,6 +46,18 @@ page that documents it. | [2.5.0](#v250) | Organization-wide config with `inherit_from` | [Across an organization](guides/organization.md) | | [2.0.0](#v200) | Configuration moved from YAML to TOML — breaking | [Migrating from v1](migration.md) | +## v2.24.0 (2026-11-22) { #v2240 } + +### Added + +* `[commit] body_max_line_length` fails a body line longer than the limit; it is off by default, and lines with a URL, a single word such as a path or a hash, and trailers are not counted, while Chinese, Japanese and Korean lines are. ([CC018](rules.md#cc018), [#730](https://github.com/commit-check/commit-check/pull/730)) +* The JSON result and the Python API list settings that are not in force, such as a misspelt key or an `inherit_from` that could not be loaded, in `notices`. ([Reading the JSON](example.md#reading-the-json), [#728](https://github.com/commit-check/commit-check/pull/728)) +* Unknown keys in `[pull_request]` are reported, with the closest real name. ([Settings nothing reads](configuration.md#settings-nothing-reads), [#728](https://github.com/commit-check/commit-check/pull/728)) + +### Changed + +* A run with no checks at all reports `skip` instead of `pass`; the exit code stays `0`. ([Python API](guides/python-api.md#the-result), [#728](https://github.com/commit-check/commit-check/pull/728)) + ## v2.23.1 (2026-11-20) { #v2231 } ### Changed diff --git a/docs/compare/tools.md b/docs/compare/tools.md index df81043..bb44738 100644 --- a/docs/compare/tools.md +++ b/docs/compare/tools.md @@ -65,7 +65,7 @@ Replace the hook: ```yaml title=".pre-commit-config.yaml" repos: - repo: https://github.com/commit-check/commit-check - rev: v2.23.1 + rev: v2.24.0 hooks: - id: check-message ``` @@ -85,6 +85,7 @@ subject_max_length = 72 # T1 subject_min_length = 5 # T8 allow_wip_commits = false # T5's default word, WIP require_body = true # B6 +body_max_line_length = 80 # B1 ``` Rule by rule: @@ -95,6 +96,7 @@ Rule by rule: | T5 `title-must-not-contain-word` (default `WIP`) | `allow_wip_commits = false` ([CC010](../rules.md#cc010)), which rejects a subject that starts with `WIP`; gitlint rejects the word anywhere in the title | | T7 `title-match-regex`, B8 `body-match-regex` | `message_pattern`, one regex over the whole message ([CC001](../rules.md#cc001)) | | T8 `title-min-length` | `subject_min_length` ([CC005](../rules.md#cc005)) | +| B1 `body-max-line-length` | `body_max_line_length` ([CC018](../rules.md#cc018)), off by default; lines with a URL, a single word with no space (a path, a hash) and trailers are not counted | | B5 `body-min-length`, B6 `body-is-missing` | `require_body` ([CC011](../rules.md#cc011)); there is no minimum length | | M1 `author-valid-email` | the `check-author-email` hook ([CC102](../rules.md#cc102)), with `author_email_pattern` | | CT1 `contrib-title-conventional-commits` | `conventional_commits`, on by default ([CC001](../rules.md#cc001)) | @@ -102,9 +104,9 @@ Rule by rule: | CC2 `contrib-disallow-cleanup-commits` | `allow_fixup_commits = false` ([CC009](../rules.md#cc009)) | | I4 `ignore-by-author-name` | `ignore_authors` | | merge, revert, fixup commits ignored | the format rules already skip the subjects git writes; [CC006](../rules.md#cc006), [CC007](../rules.md#cc007) and [CC009](../rules.md#cc009) decide whether they are allowed | -| T2–T4, T6 whitespace and tab rules, T3 trailing punctuation, B1–B4 body line rules, B7 changed-file mention, user-defined Python rules | no equivalent | +| T2–T4, T6 whitespace and tab rules, T3 trailing punctuation, B2–B4 body whitespace, tab and blank-line rules, B7 changed-file mention, user-defined Python rules | no equivalent | -The last row is the honest gap: if your policy depends on body line length or +The last row is the honest gap: if your policy depends on whitespace rules or a custom rule written in Python, gitlint still does that and Commit Check does not. What you gain is the rest of this page: branch names, authors, the Action, the App, and a release that is current. @@ -114,7 +116,7 @@ Action, the App, and a release that is current. - You want the pull request title checked and nothing else: `action-semantic-pull-request`. - You are in a JavaScript repository with husky and want plugins: commitlint. - You need sign-off with a remediation flow: the DCO app, or DCO-2. -- You rely on gitlint's body line rules or your own Python rules: gitlint. +- You rely on gitlint's whitespace rules or your own Python rules: gitlint. - You want one policy for messages, branches and authors, the same everywhere a commit is made and checked, with a hosted option that needs no workflow file: Commit Check. diff --git a/docs/configuration.md b/docs/configuration.md index b882cac..99ae2d3 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -86,10 +86,12 @@ $ echo "feat: add streaming support" | commit-check -m ⚠ unknown setting [commit] subject_max_lenght is ignored; did you mean subject_max_length? ``` -It is a warning, not an error: the exit code and the JSON on stdout do not -change. The top-level `warn` list and the -[`[jira]`](guides/github-app.md#jira-ticket-references) and -[`[pull_request]`](#pull-requests-every-commit-or-the-squash-message) sections +It is a warning, not an error: the exit code does not change, and +`--format json` lists the same line in +[`notices`](example.md#reading-the-json). The +[`[pull_request]`](#pull-requests-every-commit-or-the-squash-message) section +is checked too, for the GitHub App's keys and the CLI's. The top-level `warn` +list and the [`[jira]`](guides/github-app.md#jira-ticket-references) section are not checked for unknown settings. The Python API reads no file at all (it takes a `config` dict), and the MCP server loads the file itself without reporting unknown settings. @@ -121,8 +123,8 @@ The value can be a GitHub shorthand, a local path or an HTTPS URL: If the target is unreachable or the format is not recognized, Commit Check ignores the inheritance and uses the local configuration alone, printing a - one-line `⊘ inherit_from ... could not be loaded` notice on stderr; the exit - code does not change. Plain HTTP URLs are rejected the same way. Only one + one-line `⊘ inherit_from ... could not be loaded` notice on stderr, also + listed in the JSON's `notices`; the exit code does not change. Plain HTTP URLs are rejected the same way. Only one level is followed: an `inherit_from` inside the parent is ignored, with a notice. A repository that stops inheriting still passes its own checks, so pin the branch when the policy matters. @@ -274,7 +276,7 @@ Used from a hook definition, with no config file anywhere in the repository: ```yaml title=".pre-commit-config.yaml" repos: - repo: https://github.com/commit-check/commit-check - rev: v2.23.1 + rev: v2.24.0 hooks: - id: check-message args: @@ -312,6 +314,7 @@ The full mapping between the three forms: | `allow_fixup_commits = true` | `CCHK_ALLOW_FIXUP_COMMITS=true` | `--allow-fixup-commits=true` | | `allow_wip_commits = false` | `CCHK_ALLOW_WIP_COMMITS=false` | `--allow-wip-commits=false` | | `require_body = false` | `CCHK_REQUIRE_BODY=false` | `--require-body=false` | +| `body_max_line_length = 72` | `CCHK_BODY_MAX_LINE_LENGTH=72` | `--body-max-line-length=72` | | `require_signed_off_by = false` | `CCHK_REQUIRE_SIGNED_OFF_BY=false` | `--require-signed-off-by=false` | | `ignore_authors = ["bot"]` | `CCHK_IGNORE_AUTHORS=bot,user` | `--ignore-authors=bot,user` | | `author_email_pattern = '^.+@example\.com$'` | `CCHK_AUTHOR_EMAIL_PATTERN=^.+@example\.com$` | `--author-email-pattern=^.+@example\.com$` | @@ -409,6 +412,7 @@ These two sit above every section, at the top of the file. | `allow_fixup_commits` | bool | true | Allow fixup commits: `fixup!`, `squash!` and `amend!` subjects. | | `allow_wip_commits` | bool | true | Allow work-in-progress commits (e.g., "WIP: "). | | `require_body` | bool | false | Require a body in the commit message. | +| `body_max_line_length` | int | 0 | Maximum length of a body line. Lines with a URL, a single word with no space (a path, a hash) and the trailer block are not counted, and commits by `dependabot[bot]` and `renovate[bot]` skip it. `0` turns the check off — see [CC018](rules.md#cc018). | | `ignore_authors` | list[str] | [] (none ignored) | List of commit authors **or co-authors** (`Co-authored-by:` lines) to bypass all commit checks. Useful for bots (e.g., `"dependabot[bot]"`, `"coderabbitai[bot]"`). | | `author_email_pattern` | str | `^.+@.+$` | Custom regex for the author email check. When empty, the built-in default pattern is used. This option only takes effect when the author_email check is enabled (`-e` / `--author-email`). | | `author_name_pattern` | str | "" (built-in default) | Custom regex for the author name check. When empty, the built-in default pattern is used (it is not disabled). This option only takes effect when the author_name check is enabled (`-n` / `--author-name`). | diff --git a/docs/example.md b/docs/example.md index 7a5cdec..7a3b2df 100644 --- a/docs/example.md +++ b/docs/example.md @@ -186,7 +186,7 @@ pushed: ```yaml title=".pre-commit-config.yaml" repos: - repo: https://github.com/commit-check/commit-check - rev: v2.23.1 + rev: v2.24.0 hooks: - id: check-no-force-push stages: [pre-push] @@ -412,5 +412,22 @@ It reports attribution, not authorship: a sentence that merely mentions a tool adds nothing, an empty list does not mean no AI was used, and a listed tool may only have assisted. +A setting that is not in force, such as a misspelt key, an `inherit_from` +that could not be loaded, a `[files]` value that cannot be used or an invalid +`CCHK_*` value, is printed on stderr and also listed in `notices`, which is +empty when none was found (a misspelt `CCHK_*` name is not one Commit Check +knows, so it goes unnoticed). A script can fail on it, though Commit Check +does not: + +```console +$ commit-check -m --format json | jq '.notices' +[ + { + "setting": "[commit] subject_max_lenght", + "message": "unknown setting [commit] subject_max_lenght is ignored; did you mean subject_max_length?" + } +] +``` + From Python, [`commit_check.api`](guides/python-api.md) returns the same result as a `dict`, without a subprocess. diff --git a/docs/guides/policies.md b/docs/guides/policies.md index 69ec4e5..f411e66 100644 --- a/docs/guides/policies.md +++ b/docs/guides/policies.md @@ -219,8 +219,9 @@ $ gh pr view 42 --json body -q .body | commit-check --ai-attribution-only Under `ai_attribution = "forbid"` a description with an agent's mark fails [CC013](../rules.md#cc013); under `"disclose"` it has to disclose the tool, -like a commit. Under the default `"ignore"` no rule runs and the check -passes; `--format json` still lists what it found in `ai_tools`, which is +like a commit. Under the default `"ignore"` no rule runs, so the status is +`skip`, unless [`ai_declaration_checkboxes`](#requiring-the-templates-ai-declaration) +is set; `--format json` still lists what it found in `ai_tools`, which is enough to label the pull request: ```console diff --git a/docs/guides/pre-commit.md b/docs/guides/pre-commit.md index 1a2fc4b..f47d075 100644 --- a/docs/guides/pre-commit.md +++ b/docs/guides/pre-commit.md @@ -8,7 +8,7 @@ Add Commit Check to `.pre-commit-config.yaml`: ```yaml title=".pre-commit-config.yaml" repos: - repo: https://github.com/commit-check/commit-check - rev: v2.23.1 + rev: v2.24.0 hooks: - id: check-message - id: check-branch @@ -36,7 +36,7 @@ That is it. The next malformed commit message is rejected before it exists. | Hook ID | Stage | Rules | |---|---|---| -| `check-message` | `commit-msg` | [CC001–CC016](../rules.md#commit-message-rules) | +| `check-message` | `commit-msg` | [CC001–CC018](../rules.md#commit-message-rules) | | `check-branch` | `pre-commit` | [CC201–CC202](../rules.md#branch-rules) | | `check-author-name` | `pre-commit` | [CC101](../rules.md#cc101) | | `check-author-email` | `pre-commit` | [CC102](../rules.md#cc102) | @@ -68,7 +68,7 @@ Options can be passed as hook arguments, which keeps everything in one file: ```yaml title=".pre-commit-config.yaml" repos: - repo: https://github.com/commit-check/commit-check - rev: v2.23.1 + rev: v2.24.0 hooks: - id: check-message args: @@ -90,7 +90,7 @@ colon, and lets the commit through: ```yaml title=".pre-commit-config.yaml" repos: - repo: https://github.com/commit-check/commit-check - rev: v2.23.1 + rev: v2.24.0 hooks: - id: check-message args: [--fix] diff --git a/docs/guides/python-api.md b/docs/guides/python-api.md index 096d437..0fe6f19 100644 --- a/docs/guides/python-api.md +++ b/docs/guides/python-api.md @@ -60,6 +60,9 @@ Every function returns the same shape: { "status": "pass" | "fail" | "skip", "warnings": 0, # how many checks have status "warn" + "notices": [ # settings not in force; [] when there are none + {"setting": "[files] max_size", "message": "..."}, + ], "checks": [ { "rule_id": "CC001", @@ -80,12 +83,16 @@ Every function returns the same shape: keeps working whatever else the result holds. - **`skip` is not `pass`.** A check skips when it never ran — the author is in `ignore_authors`, or there was nothing to check — and the top-level `status` - is `skip` only when every check skipped. A skipped run validated nothing, so + is `skip` when every check skipped, or when no check ran at all. A skipped run validated nothing, so do not read it as approval. When the author or a co-author is in `ignore_authors`, the check's `reason` names them. - **`warn`** is a rule listed under the config's `warn`: reported in full, never a failure. The top-level `status` stays `pass`, and `warnings` counts them. +- **`notices`** lists the settings in `config` that are not in force, such as + a `[files]` value that cannot be used and so turns its rule off. Unlike a + config file's, the dict's keys are not checked: an unknown key is ignored + without a notice. - **`fix`** is non-empty only when the correction is mechanical, so it can be applied as it stands; otherwise follow `suggest`. [Reading the JSON](../example.md#reading-the-json) lists the cases. diff --git a/docs/rules.md b/docs/rules.md index 233b251..bf48191 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -98,6 +98,8 @@ Run with `-m` / `--message`. | [CC014](#cc014) | `ai-disclosure` | AI assistance is not disclosed with an accepted trailer | `-m` | ⚪ Off | | [CC015](#cc015) | `ai-co-author` | An AI tool is credited as a co-author | `-m` | ⚪ Off | | [CC016](#cc016) | `ai-signoff` | An AI tool signed off the commit | `-m` | ⚪ Off | +| [CC017](#cc017) | `ai-author` | An AI tool is the commit author | `-m` | ⚪ Off | +| [CC018](#cc018) | `body-max-line-length` | Body lines must be at most `{max_len}` characters | `-m` | ⚪ Off | @@ -786,6 +788,57 @@ tool set them. All four outrank `user.name` and `user.email`. trust to commit on its own. * Top-level `warn = ["ai_author"]` reports the rule without failing the run. +### body-max-line-length (CC018) { #cc018 } + +**What it does** + +Checks that no line of the commit body is longer than a configured number of +characters. The subject is CC004's to measure, so it is not counted here. + +**Why is this bad?** + +git does not wrap a message. `git log`, `git show` and the patches that +`git format-patch` writes print each line as it was typed, so an unwrapped +paragraph runs off the side of a terminal or wraps mid-word. 72 columns +leaves room for the four spaces `git log` indents the body by inside an +80-column terminal. + +**Example** + +```text +fix: retry the upload when the token expires + +The upload used to fail for good when the token expired halfway through a long transfer, so users had to start again. +``` + +Use instead: + +```text +fix: retry the upload when the token expires + +The upload used to fail for good when the token expired halfway +through a long transfer, so users had to start again. +``` + +**Options** + +* `commit.body_max_line_length` — the limit, in characters. `72` is the usual + choice. Defaults to `0`, which turns the rule off. A Chinese, Japanese or + Korean character counts as one character, though a terminal shows it two + columns wide. + +**Not counted** + +* A line with a URL, and a line that is one word with no space, such as a + long path or a hash. Wrapping them breaks them. A line of Chinese, Japanese + or Korean has no spaces either, but it is prose, so it is counted. +* The trailer block at the end of the message, read the same way as for + CC011: a `Co-authored-by:` line is as long as the name and address in it. +* A merge commit whose subject a merge tool wrote (`Merge branch '...'`, + `Merge pull request #...`), since the tool wrote its body too. A merge with + a subject of your own is checked. Also commits by `dependabot[bot]` and + `renovate[bot]`, which copy release notes into the body. + ## Author rules ### author-name (CC101) { #cc101 }