Repository navigation
fix(commit-messages): drop the g and y flags so every subject is tested from its start - #57
Merged
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
commit-messagesgate built one RegExp fromgate.flagsand reused it for every commit subject. Withgoryin the flags,lastIndexmoved after each match, so the next subject was tested from the middle and a subject that follows the pattern could fail. The gate now stripsgandythe way theabsentandno-newgates already do.Fixes #56. Reported by Matt Abate.
Change
src/core.ts: thecommit-messagescase builds its RegExp with(gate.flags ?? "").replace(/[gy]/g, "").test/release-015.test.ts: a regression test with three conventional subjects under the flagsg,yandgi.CHANGELOG.md: the fix under Unreleased.Evidence
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-messagesgate setsflagscontaininggory; those now pass subjects that match the pattern. Every other spec and gate behaves as before.