diff --git a/AGENTS.md b/AGENTS.md index 5332f57..0699705 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -19,14 +19,14 @@ so the pages go stale on their own: a release happens elsewhere and nothing in t A draft is not one, and you cannot tell by looking for a tag: a draft can be saved against a tag that already exists, and publishing to PyPI is a separate step from publishing the GitHub release. Read the published release, or ask PyPI as above — PyPI is what the pin check compares against, since that is what a reader installs. -2. **Check the install pins.** The pre-commit snippets pin a revision with `rev:`, and a stale pin is invisible: the snippet keeps working, it just installs an older release than the page around it describes. +2. **Check the install pins.** The pre-commit snippets pin a revision with `rev:`, and the Bitbucket snippets pin the pipe with `pipe: commit-check/commit-check:X.Y.Z` (each release publishes a pipe of the same version). A stale pin is invisible: the snippet keeps working, it just installs an older release than the page around it describes. These are the only version-pinned snippets — the GitHub Action is referenced by its moving major tag (`commit-check-action@v2`) and `uvx commit-check-mcp` carries no version, so neither goes stale. ```console - $ grep -rn "rev: v" docs | grep -v docs/blog + $ grep -rnE "rev: v|pipe: commit-check/" docs | grep -v -e docs/blog -e docs/changelog.md ``` - Every one of those must name the released version. **Blog posts are excluded on purpose** — they are dated records of what was current when they were written, and moving their pins forward would falsify them. Never touch them. + Every one of those must name the released version. **Blog posts and changelog entries are excluded on purpose** — they are dated records of what was current when they were written, and moving their pins forward would falsify them. Never touch them. 3. **Check the changelog.** `docs/changelog.md` must have an entry for the latest release, and that entry must carry its **release date**, not `(unreleased)`: diff --git a/docs/changelog.md b/docs/changelog.md index a5e57c6..ac8c8fa 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -11,6 +11,7 @@ page that documents it. | Version | What changed | Documented in | |---|---|---| +| [2.24.2](#v2242) | A Bitbucket Pipelines pipe runs `commit-check-ci` in a step with no install | [Bitbucket Pipelines](guides/other-ci.md#bitbucket-pipelines) | | [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) | @@ -46,6 +47,12 @@ 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.2 (2026-11-24) { #v2242 } + +### Added + +* The Commit Check pipe for Bitbucket Pipelines: `- pipe: commit-check/commit-check:2.24.2` checks a pull request with no `image` and no install, and every release publishes a pipe of the same version. ([Bitbucket Pipelines](guides/other-ci.md#bitbucket-pipelines), [#736](https://github.com/commit-check/commit-check/pull/736)) + ## v2.24.1 (2026-11-23) { #v2241 } ### Fixed diff --git a/docs/compare/tools.md b/docs/compare/tools.md index cb00b12..1fc3aa1 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.24.1 + rev: v2.24.2 hooks: - id: check-message ``` diff --git a/docs/configuration.md b/docs/configuration.md index 9f7a6aa..2cee94b 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -276,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.24.1 + rev: v2.24.2 hooks: - id: check-message args: diff --git a/docs/example.md b/docs/example.md index 0dae860..250f315 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.24.1 + rev: v2.24.2 hooks: - id: check-no-force-push stages: [pre-push] diff --git a/docs/guides/integrations.md b/docs/guides/integrations.md index ff82c7d..3d6ed47 100644 --- a/docs/guides/integrations.md +++ b/docs/guides/integrations.md @@ -71,7 +71,8 @@ push and pull request, with no workflow file and no CI minutes. One job in the pipeline runs `commit-check-ci`, which finds the merge or pull request and checks its branch, every commit it adds and, if asked, its title -and description. On GitLab a component from the CI/CD Catalog adds that job. +and description. On GitLab a component from the CI/CD Catalog adds that job, +and on Bitbucket a pipe runs it in a step. [Set it up →](other-ci.md) ## MCP server diff --git a/docs/guides/other-ci.md b/docs/guides/other-ci.md index d3b7846..4263f74 100644 --- a/docs/guides/other-ci.md +++ b/docs/guides/other-ci.md @@ -8,7 +8,9 @@ and checks the source branch and every commit the request adds, against the same `cchk.toml` as the hook and the Action. The title, the description, each commit's author and the files it changes are one option away. On GitLab the [Commit Check component](https://gitlab.com/explore/catalog/commit-check/commit-check) -in the CI/CD Catalog adds the job for you. +in the CI/CD Catalog adds the job for you, and on Bitbucket the +[Commit Check pipe](https://bitbucket.org/commit-check/commit-check) runs it +in a step. On Azure Pipelines, and on any other CI, the job is [written by hand](#azure-pipelines). @@ -187,8 +189,6 @@ In a job written by hand they are `--pr-title` and `--pr-body-ai-attribution`. ## Bitbucket Pipelines ```yaml title="bitbucket-pipelines.yml" -image: python:3.13 - pipelines: pull-requests: '**': @@ -197,10 +197,13 @@ pipelines: clone: depth: full script: - - pip install commit-check - - commit-check-ci + - pipe: commit-check/commit-check:2.24.2 ``` +The pipe runs `commit-check-ci` from the commit-check release of the same +version, in an image of its own, so the step needs no `image` and no +install. Its output is the same as on GitLab. + - `depth: full` gives the step the pull request's whole history. With a clone that ends inside the pull request the step fails and names this setting, rather than pass with commits unchecked. @@ -208,24 +211,79 @@ pipelines: step runs. The checks stop at `BITBUCKET_COMMIT`, the pull request's own last commit, so commits that only came in with that merge are not checked. The rebase check judges that commit too, not the merge. -- The output is the same as on GitLab, and so are the options of a - [job written by hand](#writing-the-job-yourself). +- Outside a pull request pipeline, such as a `branches` pipeline, the pipe + checks the branch and the last commit only. + +Each check is a variable, with the same defaults as the +[component's inputs](#gitlab-ci): + +| Variable | Default | What it checks | +|---|---|---| +| `MESSAGE` | `true` | The message of every commit the pull request adds. | +| `BRANCH` | `true` | The name of the source branch, and `require_rebase_target` if it is set. | +| `AUTHOR_NAME` | `false` | The author name of every commit. | +| `AUTHOR_EMAIL` | `false` | The author email of every commit. | +| `FILES` | `false` | The files every commit changes, against the [`[files]` rules](../rules.md#push-rules). | +| `PR_TITLE` | `false` | The title, with the message rules a one-line title can meet. | +| `PR_BODY_AI_ATTRIBUTION` | `false` | The description, against the AI attribution rules. | + +```yaml + - pipe: commit-check/commit-check:2.24.2 + variables: + AUTHOR_EMAIL: 'true' + BRANCH: 'false' +``` + +A setting from `cchk.toml` can come from a `CCHK_` variable in the same +place, such as `CCHK_SUBJECT_MAX_LENGTH: '72'`. + +### Writing the step yourself + +To pick the image or call the command your own way, install commit-check in +the step: + +```yaml title="bitbucket-pipelines.yml" +image: python:3.13 + +pipelines: + pull-requests: + '**': + - step: + name: Commit Check + clone: + depth: full + script: + - pip install commit-check + - commit-check-ci +``` + +The variables above are options of `commit-check-ci`, as in a +[GitLab job written by hand](#writing-the-job-yourself): `AUTHOR_EMAIL: 'true'` +is `--author-email`. ### Pull request title and description Bitbucket gives the step the pull request's id but not its title or -description, so the command reads them from the Bitbucket API. Create a +description, so the pipe reads them from the Bitbucket API. Create a [repository access token](https://support.atlassian.com/bitbucket-cloud/docs/repository-access-tokens/) with the **Pull requests: Read** scope, store it as a secured repository variable named `BITBUCKET_ACCESS_TOKEN`, and switch the two checks on: ```yaml - - commit-check-ci --pr-title --pr-body-ai-attribution + - pipe: commit-check/commit-check:2.24.2 + variables: + PR_TITLE: 'true' + PR_BODY_AI_ATTRIBUTION: 'true' + BITBUCKET_ACCESS_TOKEN: $BITBUCKET_ACCESS_TOKEN ``` -Without the variable, or with a token Bitbucket refuses, the two checks fail +In a step written by hand they are `commit-check-ci --pr-title +--pr-body-ai-attribution`, and the variable reaches the command without +being named. + +Without the token, or with one Bitbucket refuses, the two checks fail and say why: a title that could not be read is never checked as empty text. -`--pr-title` and `--pr-body-ai-attribution` work as in the +The two checks work as in the [GitLab section](#merge-request-title-and-description). Editing a pull request does not start a pipeline, so run the step again after an edit. diff --git a/docs/guides/pre-commit.md b/docs/guides/pre-commit.md index a13b16f..7767133 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.24.1 + rev: v2.24.2 hooks: - id: check-message - id: check-branch @@ -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.24.1 + rev: v2.24.2 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.24.1 + rev: v2.24.2 hooks: - id: check-message args: [--fix] diff --git a/tests/docs_sync_test.py b/tests/docs_sync_test.py index 29f8f48..74bc000 100644 --- a/tests/docs_sync_test.py +++ b/tests/docs_sync_test.py @@ -170,6 +170,12 @@ def test_no_page_hardcodes_a_rule_count(self): #: A pre-commit revision pin, e.g. ``rev: v2.13.1``. _REV_PIN = re.compile(r"^\s*rev:\s*v(\d+\.\d+\.\d+)\s*$", re.M) +#: A Bitbucket pipe pin, e.g. ``pipe: commit-check/commit-check:2.24.2``. The +#: pipe is published with each release under the same version. +_PIPE_PIN = re.compile( + r"^\s*-?\s*pipe:\s*commit-check/commit-check:(\d+\.\d+\.\d+)\s*(?:#.*)?$", re.M +) + class TestDocumentedRevisions: """The revisions the install snippets pin are the released version. @@ -183,7 +189,7 @@ class TestDocumentedRevisions: """ def test_pinned_revisions_match_the_released_version(self): - """Every ``rev:`` outside the blog names the installed version.""" + """Every ``rev:`` and pipe pin outside the blog names the installed version.""" installed = version("commit-check") stale = [] for page in DOCS.rglob("*.md"): @@ -191,10 +197,11 @@ def test_pinned_revisions_match_the_released_version(self): # were written, and moving their pins forward would falsify them. if "blog" in page.relative_to(DOCS).parts: continue - for pinned in _REV_PIN.findall(page.read_text("utf-8")): + text = page.read_text("utf-8") + for pinned in _REV_PIN.findall(text) + _PIPE_PIN.findall(text): if pinned != installed: stale.append( - f"{page.relative_to(DOCS)}: pins v{pinned}, " + f"{page.relative_to(DOCS)}: pins {pinned}, " f"the released version is {installed}" ) assert not stale, "install snippets are out of date:\n " + "\n ".join(stale)