From 9a9f454be59475b0d0e8b38c4ededb813cd423da Mon Sep 17 00:00:00 2001 From: Mario Campos Date: Tue, 6 Oct 2026 10:47:23 -0500 Subject: [PATCH 1/5] Hoist core of `changenotes.mts assemble` into own function --- pr-checks/changenotes.ts | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/pr-checks/changenotes.ts b/pr-checks/changenotes.ts index 933d255cd5..a5888a4114 100755 --- a/pr-checks/changenotes.ts +++ b/pr-checks/changenotes.ts @@ -50,6 +50,28 @@ function getChangenotes(): ChangenoteFile[] { }); } +/** + * Populates the '[UNRELEASED]' section of CHANGELOG.md with the contents + * of the changenotes in {@link CHANGENOTES_DIR} and then deletes those changenotes. + * @param contents The contents of CHANGELOG.md + * @returns The updated contents of CHANGELOG.md + */ +export function transferChangenotesToChangelog(contents: string): string { + const changenotes = getChangenotes(); + const changenoteBodies = changenotes.map((c) => c.content); + const changenotePaths = changenotes.map((c) => c.absolutePath); + + const changelog = parseChangelog(contents); + addBodyLinesToUnreleasedSection(changelog, changenoteBodies); + const updatedChangelog = renderChangelog(changelog); + + for (const p of changenotePaths) { + fs.unlinkSync(p); + } + + return updatedChangelog; +} + const entryPoint = process.argv[1]; if (entryPoint && import.meta.url === pathToFileURL(entryPoint).href) { try { @@ -91,26 +113,13 @@ function usage(): ExitCode { function assemble(): ExitCode { try { - const changenotes = getChangenotes(); - const changenoteBodies = changenotes.map((c) => c.content); - const changenotePaths = changenotes.map((c) => c.absolutePath); - withChangelog((contents) => { - const changelog = parseChangelog(contents); - addBodyLinesToUnreleasedSection(changelog, changenoteBodies); - return renderChangelog(changelog); + return transferChangenotesToChangelog(contents); }, {}); - - // Delete changenotes only after successful processing. - for (const p of changenotePaths) { - fs.unlinkSync(p); - } - return ExitCode.Success; } catch (e) { console.error("Failed to assemble changenotes to 'CHANGELOG.md'", e); } - return ExitCode.Failure; } From fb4048e3e76e624a364b1f97ca4017bd9d92d626 Mon Sep 17 00:00:00 2001 From: Mario Campos Date: Tue, 6 Oct 2026 10:51:08 -0500 Subject: [PATCH 2/5] Transfer change-notes to CHANGELOG.md via update-release-branch.ts --- pr-checks/update-release-branch.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pr-checks/update-release-branch.ts b/pr-checks/update-release-branch.ts index 93e50f7ad2..736e95b618 100755 --- a/pr-checks/update-release-branch.ts +++ b/pr-checks/update-release-branch.ts @@ -23,6 +23,7 @@ import { parseArgs } from "node:util"; import { type ApiClient, getApiClient } from "./api-client"; import * as changelog from "./changelog"; +import { transferChangenotesToChangelog } from "./changenotes"; import { DryRunOption, REPO_ROOT } from "./config"; import { getCurrentVersion, @@ -693,7 +694,10 @@ export async function prepareNewBranch( console.log("Updating changelog"); changelog.withChangelog( - (contents) => changelog.setVersionAndDate(version, contents), + (contents) => { + const populatedContents = transferChangenotesToChangelog(contents); + return changelog.setVersionAndDate(version, populatedContents); + }, { ...options, initChangelog: true }, ); From badda692f46e206a8144c3017fb33d8417b31cc6 Mon Sep 17 00:00:00 2001 From: Mario Campos Date: Tue, 6 Oct 2026 12:16:16 -0500 Subject: [PATCH 3/5] Trim whitespace of change-notes before insertion --- pr-checks/changenotes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr-checks/changenotes.ts b/pr-checks/changenotes.ts index a5888a4114..d05f4ea892 100755 --- a/pr-checks/changenotes.ts +++ b/pr-checks/changenotes.ts @@ -58,7 +58,7 @@ function getChangenotes(): ChangenoteFile[] { */ export function transferChangenotesToChangelog(contents: string): string { const changenotes = getChangenotes(); - const changenoteBodies = changenotes.map((c) => c.content); + const changenoteBodies = changenotes.map((c) => c.content.trim()); const changenotePaths = changenotes.map((c) => c.absolutePath); const changelog = parseChangelog(contents); From 0f6901c9a809585a1989e73114ffc5f81a356445 Mon Sep 17 00:00:00 2001 From: Mario Campos Date: Tue, 6 Oct 2026 13:52:08 -0500 Subject: [PATCH 4/5] Commit change-note deletions --- pr-checks/update-release-branch.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr-checks/update-release-branch.ts b/pr-checks/update-release-branch.ts index 736e95b618..d6d50f6287 100755 --- a/pr-checks/update-release-branch.ts +++ b/pr-checks/update-release-branch.ts @@ -701,7 +701,7 @@ export async function prepareNewBranch( { ...options, initChangelog: true }, ); - runGit(["add", "CHANGELOG.md"], { + runGit(["add", "CHANGELOG.md", "unreleased-change-notes"], { dryRun: options.dryRun, }); runGit(["commit", "-m", `Update changelog for v${version}`], { From aae22cc693c64bb85f59e3376879149e16e6889c Mon Sep 17 00:00:00 2001 From: Mario Campos Date: Tue, 6 Oct 2026 14:50:28 -0500 Subject: [PATCH 5/5] Use config vars over hardcoded literals --- pr-checks/update-release-branch.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pr-checks/update-release-branch.ts b/pr-checks/update-release-branch.ts index d6d50f6287..9d46fd3ecd 100755 --- a/pr-checks/update-release-branch.ts +++ b/pr-checks/update-release-branch.ts @@ -24,7 +24,12 @@ import { parseArgs } from "node:util"; import { type ApiClient, getApiClient } from "./api-client"; import * as changelog from "./changelog"; import { transferChangenotesToChangelog } from "./changenotes"; -import { DryRunOption, REPO_ROOT } from "./config"; +import { + CHANGELOG_FILE, + CHANGENOTES_DIR, + DryRunOption, + REPO_ROOT, +} from "./config"; import { getCurrentVersion, replaceVersionInPackageJson, @@ -701,7 +706,7 @@ export async function prepareNewBranch( { ...options, initChangelog: true }, ); - runGit(["add", "CHANGELOG.md", "unreleased-change-notes"], { + runGit(["add", CHANGELOG_FILE, CHANGENOTES_DIR], { dryRun: options.dryRun, }); runGit(["commit", "-m", `Update changelog for v${version}`], {