Skip to content

Commit 697789a

Browse files
donjor-agent[bot]donjor
authored andcommitted
fix(fork): a fold keeps a split piece's repair line when its owner ends in (#N) (#1598)
## Problem `fork:fold` tells a split piece from a squash-landed fixup by the trailing ` (#N)` on its subject. A piece repeats its owner's subject, so an owner such as `fix(server): provider spawns drop another harness identity (#108)` makes its piece look landed. The fold then lists the throwaway piece sha instead of the mover, and `fork:fold prove` refuses the member guard. ## Change `memberLine` checks the repair line under `Squashes:` first: | Fixup member | Renders as | | --- | --- | | carries a repair line | that repair line | | no repair line, ` (#N)` marker | a landed member with its link | | neither | refused, as before | ## Scope and approval Found while splitting movers for #1493, batch B8; the #1591 change introduced the marker test. ## Verification | Check | Result | | --- | --- | | `vp test run scripts/fork-fold.test.ts` | exit 0, 35 tests | | new case without the fix | fails | | `vp lint`, `vp fmt --check` on both files | exit 0, exit 0 | | `vp run fork:ci` | exit 0 | Claude Opus 5.5, Claude Code. ## Fork trailers Fork-Domain: fork-meta Fork-Tier: core Fork-Upstreamable: no Co-authored-by: donjor <[email protected]>
1 parent 3831e40 commit 697789a

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

‎scripts/fork-fold.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,22 @@ it("lists a squash-landed fixup as a member, keeping its pull request link", ()
228228
]);
229229
});
230230

231+
it("renders a piece of an owner whose subject ends in a marker as its repair line", () => {
232+
const owner = commit("aaaa1111", {
233+
subject: "fix(server): beta (#108)",
234+
message: "fix(server): beta (#108)\n",
235+
});
236+
const repairLine = "- 9999999 test(fork): mover";
237+
const piece = commit("cccc2222", {
238+
subject: "fixup! fix(server): beta (#108)",
239+
message: `fixup! fix(server): beta (#108)\n\nSquashes:\n\n${repairLine}\n`,
240+
});
241+
const folded = foldMessage({ members: [owner, piece] });
242+
assert.include(folded, repairLine);
243+
assert.notInclude(folded, "cccc2222");
244+
assert.deepStrictEqual(squashedMembers(folded), ["aaaa1111", "9999999"]);
245+
});
246+
231247
it("carries an earlier fold's links into the next fold", () => {
232248
const earlier = commit("cccc3333", {
233249
subject: "feat(web): folded (#1355)",

‎scripts/fork-fold.ts‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,10 @@ const squashesLines = (message: string): ReadonlyArray<string> => {
324324

325325
/**
326326
* A `fixup!` subject marks a split piece of a Fork-Repair commit, or a fixup
327-
* landed by squash pull request, which carries its ` (#N)` marker instead.
327+
* landed by squash pull request. A piece carries its repair line under
328+
* `Squashes:`; a landed fixup carries its ` (#N)` marker instead. The repair
329+
* line decides, since a piece's subject repeats an owner subject that may end
330+
* in a marker of its own.
328331
*/
329332
const FIXUP_SUBJECT = "fixup! ";
330333

@@ -343,14 +346,14 @@ const firstSquashesLine = (message: string): string | undefined => squashesLines
343346
* its own, so it renders like any member and its pull request link survives.
344347
*/
345348
const memberLine = (member: FoldCommit): string => {
346-
if (member.subject.startsWith(FIXUP_SUBJECT) && !SQUASH_MARKER.test(member.subject.trim())) {
349+
if (member.subject.startsWith(FIXUP_SUBJECT)) {
347350
const repair = firstSquashesLine(member.message);
348-
if (repair === undefined) {
351+
if (repair !== undefined) return repair;
352+
if (!SQUASH_MARKER.test(member.subject.trim())) {
349353
throw new FoldError(
350354
`${member.short} ${member.subject}: a fixup! member carries no repair line under Squashes:`,
351355
);
352356
}
353-
return repair;
354357
}
355358
const links = forkPullRequests(member.message)
356359
.filter((ref) => !member.subject.includes(ref))

0 commit comments

Comments
 (0)