Skip to content

feat(ci): a gate keeps commit messages in the house style (#929) - #930

Merged
obrien-k merged 1 commit into
mainfrom
ci/commit-message-gate
Oct 10, 2026
Merged

obrien-k merged 1 commit into
mainfrom
ci/commit-message-gate

Conversation

@obrien-k

Copy link
Copy Markdown
Member

Closes #929.

Rebase-merge lands each commit message on main verbatim, so a defect that merges is permanent. This adds a gate at the two points where a message can still be fixed. Existing history is not rewritten.

What it adds

  • src/lib/commitMessage.ts: a pure checker, run as npm run commits:check.
    • Fails: no lowercase Conventional Commits type, a subject wrapped onto line 2, a subject over 100 characters before its (#NNN) suffix, WIP, and a leftover fixup! commit on a PR.
    • Warns: past-tense or -ing subjects, and a breaking change marked only one way (! with no BREAKING CHANGE: footer, or the reverse). It reads text, not the diff, so these cannot fail.
    • Ignores: messages git writes itself, such as merges and reverts.
  • .husky/commit-msg: runs the check at authorship. fixup! passes here, as a step towards --autosquash.
  • A Commit messages step in the test job: checks the PR's commits, which it gets from the GitHub API because the checkout is shallow. test is already required, so branch protection is unchanged. It covers --no-verify, the web editor and bots.
  • AGENTS.md: the house style, under Commit workflow step 4.

The script takes its input from environment variables and never reads stdin, so it avoids the fd 0 failures check-changelog.ts documents.

Verification

  • commitMessage.spec.ts: 26 tests built from real commits on main. Breaking the suffix exclusion and the wrap check is caught by 2 of them.
  • The full unit suite passes: 3735 tests.
  • Over the last 400 commits on main, the gate reports the same 8 failures as the audit in Resolve verbose commit slop: gate commit messages at commit time and per-PR #929.
  • I ran the CI path's API → file → gate pipeline over the commits of the last 40 merged PRs. All 45 pass.
  • The hook exits 0 on a good message and 1 on a wrapped one. This PR's own commit went through it.
  • Lizard: max CCN 8, max function NLOC 31.

🤖 Generated with Claude Code

Rebase-merge lands each message on main verbatim, so a defect that
merges is permanent: fixing it means force-pushing main, moving release
tags and stranding stellar-compose's submodule pin. Since 2026-08, 9 of
369 commits shipped with a subject wrapped onto line 2, one far past any
length a log view shows, or a breaking change marked only one way.

lib/commitMessage.ts is the pure checker, run as npm run commits:check.
Errors are what the log shows going wrong: no lowercase type, a wrapped
subject, over 100 characters before the (#NNN) suffix, WIP, and a
leftover fixup! commit on a PR. Mood and breaking-change markers only
warn, because the checker reads text, not the diff.

Two callers, each naming its input by environment variable, and neither
reading stdin (check-changelog.ts broke twice on fd 0):

- .husky/commit-msg passes git's message file, and lets fixup! through
  at authorship, where it is a normal step towards --autosquash.
- A Commit messages step in the required test job passes the PR's
  commits from the GitHub API, catching --no-verify, the web editor and
  bots. The API, not git, because the CI checkout is shallow.

Existing history is not rewritten. Over the last 400 commits on main
the gate reports the same 8 failures the audit in #929 found, and all
45 commits from the last 40 merged PRs pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 2 minor

Alerts:
⚠ 2 issues (≤ 0 issues of at least minor severity)

Results:
2 new issues

Category Results
Comprehensibility 2 minor

View in Codacy

🟢 Metrics 39 complexity

Metric Results
Complexity 39

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@obrien-k obrien-k left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@obrien-k
obrien-k merged commit 3cdba10 into main Oct 10, 2026
5 of 6 checks passed
@obrien-k
obrien-k deleted the ci/commit-message-gate branch October 10, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Resolve verbose commit slop: gate commit messages at commit time and per-PR

1 participant