Skip to content

Commit 476a5d4

Browse files
authored
chore(release): skip empty categories in release notes (#2588)
1 parent 26ef9ba commit 476a5d4

File tree

2 files changed

+8
-24
lines changed

2 files changed

+8
-24
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,9 @@ the template we currently use:
359359
> - Fix #2
360360
361361
Make sure you're on latest `trunk`, then run
362-
`yarn release-notes <last version> <this version>` to get a list of user-facing
363-
changes. You will likely need to prune and rewrite some of these entries.
362+
`node --run release-notes -- <last version> <this version>` to get a list of
363+
user-facing changes. You will likely need to prune and rewrite some of these
364+
entries.
364365

365366
<!-- References -->
366367

scripts/internal/release-notes.mts

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type Group =
1919
| "visionos"
2020
| "windows";
2121

22-
type Changes = Record<string, Record<Group, string[]>>;
22+
type Changes = Record<string, Partial<Record<Group, string[]>>>;
2323

2424
function assertCategory(category: string): asserts category is "feat" | "fix" {
2525
if (category !== "feat" && category !== "fix") {
@@ -85,33 +85,16 @@ function sanitizeGroup(group: string): Group {
8585
}
8686

8787
function parseCommits(commits: Commit[]): Changes {
88-
const changes: Changes = {
89-
feat: {
90-
general: [],
91-
android: [],
92-
apple: [],
93-
ios: [],
94-
macos: [],
95-
visionos: [],
96-
windows: [],
97-
},
98-
fix: {
99-
general: [],
100-
android: [],
101-
apple: [],
102-
ios: [],
103-
macos: [],
104-
visionos: [],
105-
windows: [],
106-
},
107-
};
88+
const changes: Changes = { feat: {}, fix: {} };
10889

10990
for (const { message } of commits) {
11091
const m = message.match(/^(feat|fix)(?:\((.*?)\))?: (.*)$/);
11192
if (m) {
11293
const [, cat, group, message] = m;
11394
assertCategory(cat);
114-
changes[cat][sanitizeGroup(group)].push(message);
95+
const g = sanitizeGroup(group);
96+
changes[cat][g] ||= [];
97+
changes[cat][g].push(message);
11598
}
11699
}
117100

0 commit comments

Comments
 (0)