Add ExtractionOptions for configurable commit-message detection#71
Add ExtractionOptions for configurable commit-message detection#71Shuiei wants to merge 3 commits into
Conversation
47479b7 to
d82ff67
Compare
Adds --commit-prefix-pattern CLI flags. The pattern is compiled to RegExp at parse time and validated to contain exactly one capture group; invalid input fails fast with a clear error pointing at an example.
d82ff67 to
749081b
Compare
It seems that a more generic solution would be to strip the prefix from the naming and allow for a regular regexp matcher - the regexp example defines the |
Agreed. The |
…tions # Conflicts: # README.md # src/extractors.test.ts
My Problem
My team's commit/PR title convention is
[LIN-123] My change, no magic words. The current detector only picks up issue IDs that are either embedded in a branch name or preceded by a magic word likeFixes/Closes, so on every release sync our commits get scanned and none of the issues link to the release. We are alsosquashing on mergewith only the body of all the commits squashed, so falling back to the branch name doesn't work either;linear-releasehas no merge commit to look at. The workarounds (retraining everyone to writeFixes LIN-123in the body, or hand-editing releases in Linear) aren't realistic, so I'm adding configuration to the CLI instead.Summary
Adds one new
syncoption for teams whose commit conventions don't fit the default magic-word detection (Fixes LIN-123,Closes LIN-123):--issue-id-pattern=<regex>detects issue IDs via a user-supplied regex applied line-by-line to the commit message. The first capture group must wrap the ID(s). Designed for PR-title conventions like[LIN-123] My change,(LIN-123): My change, orLIN-123: My changethat don't include a magic word.^) match at most once per line; unanchored patterns find every occurrence (e.g.[LIN-1] [LIN-2] thing).gflag internally somatchAlliterates every occurrence; the captured text is fed through the existing identifier matcher (uppercase normalization, leading-zero rejection, comma/and/&list grammar).extractLinearIssueIdentifiersForCommit) and the revert path (extractRevertedIssueIdentifiersForCommit).The README ships four copy-pasteable recipes covering the common conventions:
Changes
src/args.ts: parses--issue-id-pattern, validates the regex (single capture group required), and surfaces it onParsedCLIArgs.commitPrefixPattern.src/extractors.ts: introducesExtractionOptions, addsmatchCommitPrefixIdentifiers, threads the option through both extractor entry points.src/scan.ts/src/index.ts: acceptsExtractionOptionsinscanCommitsand wires the CLI value through, with verbose logging when the option is active.README.md: new Issue Detection section with the four recipes; CLI table updated.issue-detection-matrix.md: behavior matrix covering the flag against representative commit titles, plus a "Things that surprise people" section spelling out the non-obvious rules (anchored-vs-unanchored, leading-zero rejection, magic-word composition, branch-name extraction).src/args.test.ts,src/extractors.test.ts,src/scan.test.ts.