Skip to content

Add --issue-pattern flag for custom subject-line identifier extraction - #117

Closed
MatthewCline-git wants to merge 1 commit into
linear:mainfrom
MatthewCline-git:feat/issue-pattern-flag
Closed

Add --issue-pattern flag for custom subject-line identifier extraction#117
MatthewCline-git wants to merge 1 commit into
linear:mainfrom
MatthewCline-git:feat/issue-pattern-flag

Conversation

@MatthewCline-git

Copy link
Copy Markdown

Summary

Closes #106.

The three built-in subject patterns in COMMON_SUBJECT_PATTERNS are all anchored to the start of the subject line, so teams that follow Conventional Commits — where the identifier appears after the type and scope — get no issue linked:

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

This adds a --issue-pattern flag that accepts a regex where group 1 captures the issue identifier. It's applied to the commit subject anywhere (not just the start), additive to the existing patterns:

linear-release sync --issue-pattern "\[([A-Z]+-[0-9]+)\]"

The pattern is validated as a legal regex at CLI entry. Invalid patterns produce a clear error:

Invalid --issue-pattern regex: Invalid regular expression: ...

Changes

  • args.ts — new --issue-pattern flag, validated and returned as issuePattern: string | null
  • extractors.tsmatchCustomSubjectPattern() applies the user regex globally to the subject, validates group 1 captures through the existing matchAllIdentifiers path; wired into extractLinearIssueIdentifiersForCommit via an optional second argument
  • scan.tsissuePattern added to ScanOptions, compiled once before the commit loop, threaded into the extractor
  • index.ts — destructured from parsed args, passed to scanCommits, added to help text

@MatthewCline-git
MatthewCline-git marked this pull request as ready for review June 30, 2026 01:37
@DanCorvesor

Copy link
Copy Markdown

Tried this branch against a real repo (GitLab CI + semantic-release, Conventional Commits) — --issue-pattern "([A-Za-z]{2,}-[0-9]+)" resolved every ticket the built-in leading-key patterns miss: mid-subject feat(api): asp-621 … and parenthesised (ASP-603) alike. Exactly the gap from #106. 🙌

One thing to fix before it's usable for live syncs: the actual releaseSyncByAccessKey mutation fails with

Field "issuePattern" is not defined by type "ReleaseDebugSinkInput"

because issuePattern is added to DebugSink, which is sent in the mutation input (--dry-run hides it since it skips the mutation). Opened a small PR against this branch that strips it from the payload while keeping it in the local sink for --verbose: MatthewCline-git#1. With that applied, live sync created real releases with all issues attached.

@RomainCscn

Copy link
Copy Markdown
Collaborator

Closing in favor of #124

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)

3 participants