Skip to content

Commit b5d6b3f

Browse files
committed
Fix release notes merge commit detection
1 parent c9cee66 commit b5d6b3f

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

scripts/get-release-notes.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,29 @@ async function main() {
4747
.split("\n")
4848
.filter(Boolean);
4949

50-
// Get all commits
50+
// Get all commits in the range
5151
const allCommitsRaw =
5252
await $`git log ${fromTag}..${toRef} --pretty=format:%H`;
5353
const allCommits = allCommitsRaw.stdout.trim().split("\n").filter(Boolean);
5454

55-
// Get all commits that are not merge commits
55+
// Get all descendants of merge commits
56+
let mergeDescendants = new Set<string>();
57+
for (const mergeSha of mergeCommits) {
58+
// Get all descendants of this merge commit (including itself)
59+
// --ancestry-path gives the commits that are descendants of mergeSha up to HEAD
60+
const descendantsRaw =
61+
await $`git log ${mergeSha}..${toRef} --ancestry-path --pretty=format:%H`;
62+
const descendants = descendantsRaw.stdout
63+
.trim()
64+
.split("\n")
65+
.filter(Boolean);
66+
descendants.forEach((sha) => mergeDescendants.add(sha));
67+
mergeDescendants.add(mergeSha); // include the merge commit itself
68+
}
69+
70+
// Non-merge commits that are NOT descendants of any merge commit
5671
const nonMergeCommits = allCommits.filter(
57-
(sha) => !mergeCommits.includes(sha)
72+
(sha) => !mergeCommits.includes(sha) && !mergeDescendants.has(sha)
5873
);
5974
// Collect all commit messages for summary
6075
let allMessages: string[] = [];

0 commit comments

Comments
 (0)