Skip to content

feat: add --issue-pattern to extract issue IDs from custom subject formats#107

Closed
olsavmic wants to merge 1 commit into
linear:mainfrom
olsavmic:feat/issue-pattern
Closed

feat: add --issue-pattern to extract issue IDs from custom subject formats#107
olsavmic wants to merge 1 commit into
linear:mainfrom
olsavmic:feat/issue-pattern

Conversation

@olsavmic

@olsavmic olsavmic commented Jun 9, 2026

Copy link
Copy Markdown

Closes #106.

What & why

Issue identifiers are only extracted from a commit subject when the identifier leads the subject — the three built-in COMMON_SUBJECT_PATTERNS are start-anchored ([ENG-123] …, (ENG-123) …, ENG-123: …). Teams using Conventional Commits put the identifier after the type/scope, so it is silently dropped:

feat(routing)[ENG-123]: add stop reordering
fix[ENG-123]: handle empty payload

--include-subjects can't recover these — it's a filter (which commits to scan), not an extractor (where the identifier is).

This adds --issue-pattern=<regex> for sync: a user-supplied regex whose group 1 is the team key and group 2 is the issue number.

linear-release sync --issue-pattern="\w+(?:\([^)]*\))?!?\[(\w+)-(\d+)\]"

Behavior

  • Matched against the commit subject (first line), like --include-subjects and the built-in subject patterns.
  • Scanned globally → a subject can yield multiple identifiers.
  • Case-insensitive; team key upper-cased, leading zeros stripped (eng-0045ENG-45); leading-zero numbers rejected — same normalization as parseMatch.
  • Additive: merged with branch-name / magic-word / built-in-subject detection and de-duplicated. Default behavior is unchanged when the flag is absent.
  • Validated at parse time — the regex must compile and expose ≥2 capture groups, otherwise a helpful error.
  • Zero-width-match guard so a loose pattern (e.g. (\w*)-(\d*)) can't loop forever.

Scope / non-goals

Wired through the add path (extractLinearIssueIdentifiersForCommit) only — the revert path (extractRevertedIssueIdentifiersForCommit) is intentionally left on the built-in magic-word gating to avoid false "reverted" attributions from arbitrary user patterns. Happy to extend it there if you'd prefer symmetry.

Implementation

  • extractors.tsmatchCustomSubjectPattern() + an optional ExtractOptions arg on extractLinearIssueIdentifiersForCommit.
  • args.ts — parse/validate --issue-pattern (compiles + ≥2 groups via a small countCapturingGroups probe).
  • scan.ts / types.ts — thread issuePattern through ScanOptions and record it on the DebugSink.
  • index.ts — help text, example, wiring.

Tests & docs

  • extractors.test.ts — Conventional Commits with/without scope and !, case/leading-zero normalization, multi-ID subjects, subject-only (body ignored), de-dup with branch name, zero-width-loop guard.
  • args.test.ts — default null, raw passthrough, empty = none, invalid-regex error, <2-groups error.
  • scan.test.ts — extraction through scanCommits + debug-sink recording.
  • README.md — new "Custom Issue Patterns" section + options-table row.

pnpm typecheck, pnpm test:ci (399 passing), pnpm lint (0 findings), and pnpm fmt:check all green locally.

…rmats

Built-in subject detection only matches identifiers that lead the subject
(`[ENG-123] …`, `(ENG-123) …`, `ENG-123: …`). Conventional Commits put the
identifier after the type and optional scope (`feat(scope)[ENG-123]: …`,
`fix[ENG-123]: …`), so it is never linked to the release. `--include-subjects`
is a filter, not an extractor, so it cannot recover the identifier either.

Add a `--issue-pattern=<regex>` flag (group 1 = team key, group 2 = issue
number) matched against the commit subject. Matching is global and
case-insensitive; the team key is upper-cased and leading zeros stripped,
leading-zero numbers rejected. It is additive to and de-duplicated with the
existing branch-name / magic-word / built-in-subject detection. The flag is
validated at parse time to compile and expose at least two capture groups.

Closes linear#106

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@olsavmic

olsavmic commented Jun 9, 2026

Copy link
Copy Markdown
Author

Closing — this duplicates the earlier #71, which proposed the same --issue-id-pattern regex flag (capture group around the ID) and was closed unmerged. Closing the companion issue #106 too. Thanks!

@olsavmic olsavmic closed this Jun 9, 2026
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.

Release CLI: --issue-pattern flag to extract issue IDs from custom subject formats (e.g. Conventional Commits)

1 participant