Skip to content

fix(commit-messages): drop the g and y flags so every subject is tested from its start - #57

Merged
renezander030 merged 1 commit into
masterfrom
fix/commit-messages-flags
Nov 3, 2026
Merged

renezander030 merged 1 commit into
masterfrom
fix/commit-messages-flags

Conversation

@renezander030

Copy link
Copy Markdown
Owner

The commit-messages gate built one RegExp from gate.flags and reused it for every commit subject. With g or y in the flags, lastIndex moved after each match, so the next subject was tested from the middle and a subject that follows the pattern could fail. The gate now strips g and y the way the absent and no-new gates already do.

Fixes #56. Reported by Matt Abate.

Change

  • src/core.ts: the commit-messages case builds its RegExp with (gate.flags ?? "").replace(/[gy]/g, "").
  • test/release-015.test.ts: a regression test with three conventional subjects under the flags g, y and gi.
  • CHANGELOG.md: the fix under Unreleased.

Evidence

  • The new test fails on master: flags g: 1 of 3 commit message(s) ... do not match ...: "fix: mend a", and passes with the fix.
  • npm ci && npm run build && npm test: 258 pass, 0 fail.
  • node dist/src/cli.js check: all 4 gates pass.

Door

two-way: a one-line change in one gate, undone by a revert.

Blast radius

Only specs whose commit-messages gate sets flags containing g or y; those now pass subjects that match the pattern. Every other spec and gate behaves as before.

…ed from its start

The commit-messages gate reused one RegExp for every commit subject. With g or y
in the flags, lastIndex moved after each match and a matching subject could fail.
Strip g and y as the absent and no-new gates do.

Fixes #56
@renezander030
renezander030 merged commit 622420a into master Nov 3, 2026
7 checks passed
@renezander030
renezander030 deleted the fix/commit-messages-flags branch November 3, 2026 15:00
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.

commit-messages gate gives wrong verdicts when flags contains g or y

1 participant