Skip to content

Add ExtractionOptions for configurable commit-message detection#71

Open
Shuiei wants to merge 3 commits into
linear:mainfrom
arc-connect:add_regex_and_nomw_options
Open

Add ExtractionOptions for configurable commit-message detection#71
Shuiei wants to merge 3 commits into
linear:mainfrom
arc-connect:add_regex_and_nomw_options

Conversation

@Shuiei
Copy link
Copy Markdown

@Shuiei Shuiei commented May 13, 2026

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 like Fixes/Closes, so on every release sync our commits get scanned and none of the issues link to the release. We are also squashing on merge with only the body of all the commits squashed, so falling back to the branch name doesn't work either; linear-release has no merge commit to look at. The workarounds (retraining everyone to write Fixes LIN-123 in the body, or hand-editing releases in Linear) aren't realistic, so I'm adding configuration to the CLI instead.

Summary

Adds one new sync option 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, or LIN-123: My change that don't include a magic word.

  • Anchored patterns (with ^) match at most once per line; unanchored patterns find every occurrence (e.g. [LIN-1] [LIN-2] thing).
  • Validation at parse time rejects invalid regexes and patterns that don't have exactly one capture group, with an example in the error message.
  • Forces the g flag internally so matchAll iterates every occurrence; the captured text is fed through the existing identifier matcher (uppercase normalization, leading-zero rejection, comma/and/& list grammar).
  • Composes with the default magic-word path (always runs) and with branch-name detection. Honored on both the add path (extractLinearIssueIdentifiersForCommit) and the revert path (extractRevertedIssueIdentifiersForCommit).
  • Squashed sub-commit dumps are stripped before the matcher runs, so they don't re-attribute references from already-merged history.

The README ships four copy-pasteable recipes covering the common conventions:

# Bracketed prefix: `[LIN-123] My PR title`
linear-release sync --issue-id-pattern='^\[(.+?)\]'

# Unanchored: catches multi-bracket titles like `[LIN-1], [LIN-2] and [LIN-3] thing, Closes LIN-4, [LIN-5]`
linear-release sync --issue-id-pattern='\[(.+?)\]'

# Parenthesised prefix: `(LIN-1): My PR title`
linear-release sync --issue-id-pattern='^\((.+?)\):'

# Colon-suffixed line-start ID: `LIN-1: My PR title`
linear-release sync --issue-id-pattern='^(\w{1,7}-[0-9]{1,9}):'

Changes

  • src/args.ts: parses --issue-id-pattern, validates the regex (single capture group required), and surfaces it on ParsedCLIArgs.commitPrefixPattern.
  • src/extractors.ts: introduces ExtractionOptions, adds matchCommitPrefixIdentifiers, threads the option through both extractor entry points.
  • src/scan.ts / src/index.ts: accepts ExtractionOptions in scanCommits and 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).
  • Tests added in src/args.test.ts, src/extractors.test.ts, src/scan.test.ts.

@Shuiei Shuiei force-pushed the add_regex_and_nomw_options branch from 47479b7 to d82ff67 Compare May 13, 2026 04:42
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.
@Shuiei Shuiei force-pushed the add_regex_and_nomw_options branch from d82ff67 to 749081b Compare May 13, 2026 04:49
@hrach
Copy link
Copy Markdown

hrach commented May 13, 2026

--commit-prefix-pattern='^\[(.+?)\]'

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 ^ anyway.

@Shuiei
Copy link
Copy Markdown
Author

Shuiei commented May 13, 2026

--commit-prefix-pattern='^\[(.+?)\]'

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 ^ anyway.

Agreed. The ^ in the example is the prefix, not the option name, so framing it as "prefix" is misleading. I'll rename it to --issue-id-pattern since it better describes the intent (how to find issue IDs in the commit message) rather than implying a position; users who want prefix-only behavior can anchor with ^; users who want to match elsewhere don't.

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.

2 participants