Skip to content

Commit 5c95993

Browse files
devversionjelbourn
authored andcommitted
build: do not generate empty changelog sections (#14581)
* Since we filter out duplicate changelog entries it can happen that a `commitGroup` shows up without any commits. e.g. there would be an empty section for `"Features"`.
1 parent bba9af8 commit 5c95993

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tools/release/changelog.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ export async function prependChangelogFromLatestTag(changelogPath: string, relea
4444
.once('error', (error: any) => reject(error))
4545
.once('finish', () => resolve());
4646
});
47-
4847
});
4948
}
5049

@@ -73,7 +72,7 @@ function createDedupeWriterOptions(changelogPath: string) {
7372
// Specify a writer option that can be used to modify the content of a new changelog section.
7473
// See: conventional-changelog/tree/master/packages/conventional-changelog-writer
7574
finalizeContext: (context: any) => {
76-
context.commitGroups.forEach((group: any) => {
75+
context.commitGroups = context.commitGroups.filter((group: any) => {
7776
group.commits = group.commits.filter((commit: any) => {
7877
// NOTE: We cannot compare the SHA's because the commits will have a different SHA
7978
// if they are being cherry-picked into a different branch.
@@ -83,7 +82,12 @@ function createDedupeWriterOptions(changelogPath: string) {
8382
}
8483
return true;
8584
});
85+
86+
// Filter out commit groups which don't have any commits. Commit groups will become
87+
// empty if we filter out all duplicated commits.
88+
return group.commits.length;
8689
});
90+
8791
return context;
8892
}
8993
};

0 commit comments

Comments
 (0)