fix(release): allow generated ledger repair

(cherry picked from commit e4a9398396)
This commit is contained in:
Vincent Koc
2026-07-11 19:36:43 -07:00
parent a050dcc38a
commit b0ccced3d8
2 changed files with 23 additions and 5 deletions
@@ -707,6 +707,12 @@ function contributionRecordMetadataReferences(record) {
return references;
}
export function renderedContributionRecordReferences(record, writeLedger) {
// Write mode replaces the existing generated record. Validating stale record
// references here would make the verifier unable to repair its own output.
return writeLedger ? [] : contributionRecordMetadataReferences(record);
}
export function contaminatingPullRequestReferences({
noteReferences,
recordedReferences,
@@ -2103,11 +2109,10 @@ function main() {
...source.revertedReferences,
...shippedExclusions.pullRequests,
]);
const effectiveRenderedRecord = options.writeLedger
? withoutExcludedContributionRecords(renderedRecord, excludedRecordedReferences)
: renderedRecord;
const effectiveRenderedRecordReferences =
contributionRecordMetadataReferences(effectiveRenderedRecord);
const effectiveRenderedRecordReferences = renderedContributionRecordReferences(
renderedRecord,
options.writeLedger,
);
let priorRecord = { legacyIssues: new Map(), pullRequests: new Map() };
if (options.seedRef) {
const seedChangelog = git(["show", `${options.seedRef}:CHANGELOG.md`]);
+13
View File
@@ -15,6 +15,7 @@ import {
highlightCountError,
persistGithubSnapshot,
releaseNoteReferences,
renderedContributionRecordReferences,
standardRevertedHash,
subtractShippedPullRequests,
withoutExcludedContributionRecords,
@@ -373,6 +374,18 @@ describe("release-note verification", () => {
).toEqual([]);
});
it("ignores the stale generated record while rewriting it", () => {
const record = {
pullRequests: new Map([
[104732, { references: [102289], thanks: ["fuller-stack-dev"] }],
]),
legacyIssues: new Map(),
};
expect(renderedContributionRecordReferences(record, true)).toEqual([]);
expect(renderedContributionRecordReferences(record, false)).toEqual([104732, 102289]);
});
it("excludes Unreleased records from a cumulative shipped tag boundary", () => {
const changelog = [
"# Changelog",