Skip to content
Merged
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
29 changes: 29 additions & 0 deletions src/extractors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,35 @@ describe("commit message magic word behavior", () => {
});
});

describe("revert branch handling", () => {
it("blocks extraction from merge commit with revert branch name", () => {
const result = extractLinearIssueIdentifiersForCommit({
sha: "abc",
branchName: "revert-571-romain/bac-39",
message: "Merge pull request #572 from org/revert-571-romain/bac-39",
});
expect(result).toEqual([]);
});

it("blocks extraction when revert branch has multiple identifiers", () => {
const result = extractLinearIssueIdentifiersForCommit({
sha: "abc",
branchName: "revert-571-romain/drive-320-and-drive-321",
message: null,
});
expect(result).toEqual([]);
});

it("blocks PR number extraction from revert branch", () => {
const result = extractPullRequestNumbersForCommit({
sha: "abc",
branchName: "revert-571-romain/bac-39",
message: "Merge pull request #572 from org/revert-571-romain/bac-39",
});
expect(result).toEqual([]);
});
});

describe("extractPullRequestNumbersForCommit", () => {
// Messages that should extract PR numbers
it.each([
Expand Down
13 changes: 13 additions & 0 deletions src/extractors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ export function extractLinearIssueIdentifiersForCommit(commit: CommitContext): s
return [];
}

// GitHub auto-generates branch names like "revert-571-romain/bac-39" for revert PRs.
// Block extraction to prevent the original issue identifier from being added to the release.
if (/(^|\/)revert-\d+-/i.test(commit.branchName ?? "")) {
log(`Skipping revert branch ${commit.branchName} for commit ${commit.sha}`);
return [];
}

const found = new Map<string, string>();

// Branch name: extract all matches (branch names are always intentional)
Expand Down Expand Up @@ -172,6 +179,12 @@ export function extractPullRequestNumbersForCommit(commit: CommitContext): numbe
return [];
}

// Skip merge commits of revert PRs — branch name like "revert-571-romain/bac-39"
if (/(^|\/)revert-\d+-/i.test(commit.branchName ?? "")) {
log(`Skipping revert merge commit ${commit.sha}`);
return [];
}

const prNumbers: number[] = [];

// GitHub squash: "Title (#123)" - must be at end of title (first line)
Expand Down