Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/extractors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,29 @@ describe("version suffix handling", () => {
expect(ids(result)).toEqual(expected);
});

// A magic word in front of a version must not match a shorter prefix (ios-17.4 -> IOS-1)
it.each([
["Fix ios-17.4 keyboard crash", []],
["Fix node-20.11 build", []],
["Fixes ios-17.4.1 crash", []],
["Fixes ENG-123, ENG-45.6", ["ENG-123"]],
])("message %j should yield %j", (message, expected) => {
const result = extractLinearIssueIdentifiersForCommit({
sha: "abc",
branchName: null,
message,
});
expect(ids(result)).toEqual(expected);
});

it("does not report a version prefix as reverted", () => {
const result = extractRevertedIssueIdentifiersForCommit({
sha: "abc",
message: 'Revert "Fix ios-17.4 keyboard crash"',
});
expect(ids(result)).toEqual([]);
});

// Legitimate identifiers should match
it.each([
["john/ios-1641-introduce-a-proper-blockview", ["IOS-1641"]],
Expand Down
4 changes: 3 additions & 1 deletion src/extractors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,10 @@ const CONTRIBUTING_PHRASES = [
/**
* Core issue ID pattern without word boundaries — used inside the magic word
* composite regex where surrounding context already provides boundaries.
* `(?![0-9])` stops the number from backtracking to a shorter prefix, which
* would otherwise let `ios-17.4` slip past the version lookahead as `ios-1`.
*/
const ISSUE_ID_CORE = `\\w{1,${MAX_KEY_LENGTH}}-[0-9]{1,9}(?!\\.\\d)`;
const ISSUE_ID_CORE = `\\w{1,${MAX_KEY_LENGTH}}-[0-9]{1,9}(?![0-9])(?!\\.\\d)`;

/**
* Build a regex that matches magic words followed by one or more issue identifiers.
Expand Down
Loading