Repository navigation
Conversation
The npm release backport cherry-picked the 'Update changelog files' commit onto trunk. When trunk gained changelog entries during npm publication, git's textual merge silently filed them under the just-published version heading, and only conflicted for packages whose '## Unreleased' section was empty (packages that shipped nothing in the release). - Recompute every release-touched changelog structurally instead of trusting the merge: entries the target branch added since the release base stay under '## Unreleased'; everything from the new version heading down is taken verbatim from the released changelog. The cherry-pick still supplies the package.json changes. - Before pushing, verify that the released portion of every package changelog is byte-identical to the published release, failing loudly (including when zero files are found to verify). - Backport each target branch independently so a failure on one branch no longer cancels the other, and reset the working copy on failure so one branch's conflict cannot poison the next backport. Fixes #81506
|
Size Change: 0 B Total Size: 7.72 MB |
- Skip released-changelog verification for packages that have never published a release instead of failing; three private packages have changelogs with no version heading, which made every finalization throw. - Sync backport target branches to the remote tip with checkout -B and reset --hard inside the recovery boundary, instead of pulling: a diverged local branch could conflict (poisoning the next branch's backport) or silently merge stale local state into the push. See #81566 (comment)
|
Flaky tests detected in d91e227. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/31785231322 adds and activates a new tab when pressing Enter at the end of a tab label in
|
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
What?
Closes #81506
Makes the npm release's changelog backport deterministic. The release tooling no longer replays the "Update changelog files" commit onto
trunkwith a baregit cherry-pickand pushes whatever comes out; it recomputes each changelog from what actually shipped, and it verifies the result before pushing anything.Why?
A three-way merge of a markdown list knows line positions, not semantics. When
trunkgains a changelog entry during the ~10-minute npm publication window, the cherry-pick files that entry under the version heading that was published minutes earlier — an entry attributed to a release that does not contain it. Worse, the merge only conflicts when the package's## Unreleasedsection was empty at release time, which is precisely the case where the package shipped nothing. So the alarm fires only for packages that were fine, and packages that shipped changes are corrupted silently, every time. That is not bad luck; it is the design, and I would gently suggest it is the wrong design.Both release cycles since July needed hand repair (#81303, #81304, #81480, #81485, #81502), and the August 12 manual recovery reproduced the same corruption it was fixing. Careful people cannot catch this, because nothing checks for it. This PR makes the tooling produce the right result, and refuse loudly when it cannot.
How?
Three changes, matching the issue's suggested fixes 1–3:
Recompute instead of replay. The changelog commit is still applied with
git cherry-pick --no-commitfor thepackage.jsonchanges the publish commit depends on, but every package changelog it touched is then rewritten byrecomputeBackportedChangelog(newtools/release/lib/released-changelog.js): entries the target branch added since the release base stay under## Unreleasedwith their subsection structure preserved, and everything from the new version heading down is taken verbatim from the released changelog. Conflicted files and cleanly-merged files go through the identical path, so the empty-## Unreleasedconflict resolves itself. If the branch's released history does not match the release base (for example, an intermediate release that was never backported), the backport refuses with an explicit error rather than guessing.rerereis disabled for the picks so a resolution recorded on someone's machine cannot leak into a release.Verify before pushing.
verifyBackportedChangelogsasserts that the released portion of every package changelog in the release tree is byte-identical on the branch tip. Anything else means an entry moved into or out of a published version section, and the push does not happen. Per the issue's warning about checks that quietly inspect nothing, finding zero changelogs to verify is itself a hard failure. The check runs inside the tool, so it covers the direct push that never becomes a PR.Independent branch backports.
finalizePreparedNpmReleasenow attemptstrunkand the plugin release branch independently and reports every failure, instead of letting the first branch's conflict cancel the second branch's perfectly applicable backport. A failed backport restores the clone toorigin/<branch>so its debris cannot poison the next target.The issue's fix 4 (a
finalizerecovery subcommand) is deliberately not included; it is a feature rather than a defect fix, and the recompute/verify functions are exported so it can be built on top of this.#81561 corrects the historical misattributions in the changelog data and is stacked on this branch.
Testing Instructions
npm run test:unit -- tools/release— covers the recompute, the verification, and the backport orchestration, including the two shapes from the August 12 incident: the entry git merges cleanly into the wrong section, and the empty-## Unreleasedconflict.End-to-end reproduction
Then, from a Gutenberg checkout on this branch, drive the backport with the two commit hashes from
git log wp-latestin the scratch repo:git show origin/main:packages/data/CHANGELOG.mdin the scratch repo should show "Landed during publish" under## Unreleasedand only "Shipped fix" under## 1.1.0 (2026-08-12)— with the old code, both end up under1.1.0. Rewording an entry in a released section ofmainbefore rerunning makes the backport refuse and push nothing.Use of AI Tools
Implemented with Claude Code (Fable 5), directed and reviewed by @sirreal.
🤖 Generated with Claude Code