feat: add --issue-pattern to extract issue IDs from custom subject formats#107
Closed
olsavmic wants to merge 1 commit into
Closed
feat: add --issue-pattern to extract issue IDs from custom subject formats#107olsavmic wants to merge 1 commit into
olsavmic wants to merge 1 commit into
Conversation
…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>
Author
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.
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_PATTERNSare start-anchored ([ENG-123] …,(ENG-123) …,ENG-123: …). Teams using Conventional Commits put the identifier after the type/scope, so it is silently dropped:--include-subjectscan't recover these — it's a filter (which commits to scan), not an extractor (where the identifier is).This adds
--issue-pattern=<regex>forsync: 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
--include-subjectsand the built-in subject patterns.eng-0045→ENG-45); leading-zero numbers rejected — same normalization asparseMatch.(\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.ts—matchCustomSubjectPattern()+ an optionalExtractOptionsarg onextractLinearIssueIdentifiersForCommit.args.ts— parse/validate--issue-pattern(compiles + ≥2 groups via a smallcountCapturingGroupsprobe).scan.ts/types.ts— threadissuePatternthroughScanOptionsand record it on theDebugSink.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 throughscanCommits+ debug-sink recording.README.md— new "Custom Issue Patterns" section + options-table row.pnpm typecheck,pnpm test:ci(399 passing),pnpm lint(0 findings), andpnpm fmt:checkall green locally.