Skip to content

Commit bc44c89

Browse files
committed
fix(release): merge live and recovered server-changes instead of either/or
Combine working-tree and git-recovered server-change files (dedup by filename) so a partial cleanup can't drop entries from the release notes.
1 parent a522872 commit bc44c89

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

scripts/enhance-release-pr.mjs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,26 @@ async function parseServerChanges() {
213213
}
214214

215215
async function getServerChangeFileData() {
216-
const liveFileData = await getLiveServerChangeFileData();
217-
if (liveFileData.length > 0) return liveFileData;
218-
219216
// The changesets version command deletes .server-changes before this script
220-
// enhances the release PR body. Recover those consumed files from the release
221-
// branch diff so they still make it into the release notes handoff.
222-
return getDeletedServerChangeFileDataFromReleaseBranch();
217+
// enhances the release PR body. We combine files still live on disk with the
218+
// ones recovered from the release branch diff, deduped by filename, rather
219+
// than picking one source or the other. This is additive so a partial cleanup
220+
// (some files deleted, some still live) can't silently drop entries. Live
221+
// files win on collision since they are the current on-disk truth.
222+
const [live, deleted] = await Promise.all([
223+
getLiveServerChangeFileData(),
224+
getDeletedServerChangeFileDataFromReleaseBranch(),
225+
]);
226+
227+
const byName = new Map();
228+
for (const fileData of deleted) {
229+
byName.set(fileData.filePath.split("/").pop(), fileData);
230+
}
231+
for (const fileData of live) {
232+
byName.set(fileData.filePath.split("/").pop(), fileData);
233+
}
234+
235+
return [...byName.values()].sort((a, b) => a.filePath.localeCompare(b.filePath));
223236
}
224237

225238
async function getLiveServerChangeFileData() {

0 commit comments

Comments
 (0)