Skip to content

Commit 071660e

Browse files
saphidclaude
andauthored
fix(server): Uncommitted review keeps a staged deletion that git pairs into a rename (pingdotgg#29571)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 6739dd7 commit 071660e

2 files changed

Lines changed: 33 additions & 16 deletions

File tree

‎apps/server/src/vcs/GitVcsDriverCore.test.ts‎

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2417,23 +2417,31 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
24172417
}),
24182418
);
24192419

2420-
it.effect("preserves a staged deletion when the removed path still exists", () =>
2421-
Effect.gen(function* () {
2422-
const cwd = yield* makeTmpDir();
2423-
yield* initRepoWithCommit(cwd);
2424-
const driver = yield* GitVcsDriver.GitVcsDriver;
2425-
yield* writeTextFile(cwd, "removed.txt", "remove me\n");
2426-
yield* git(cwd, ["add", "removed.txt"]);
2427-
yield* git(cwd, ["commit", "-m", "add removable file"]);
2428-
yield* git(cwd, ["rm", "--cached", "removed.txt"]);
2420+
it.effect.each([
2421+
{ stagedCopy: false, expected: ["deleted file mode", "-remove me"] },
2422+
{ stagedCopy: true, expected: ["rename from removed.txt", "rename to copy.txt"] },
2423+
])(
2424+
"preserves a staged deletion when the removed path still exists (staged copy: $stagedCopy)",
2425+
({ stagedCopy, expected }) =>
2426+
Effect.gen(function* () {
2427+
const cwd = yield* makeTmpDir();
2428+
yield* initRepoWithCommit(cwd);
2429+
const driver = yield* GitVcsDriver.GitVcsDriver;
2430+
yield* writeTextFile(cwd, "removed.txt", "remove me\n");
2431+
yield* git(cwd, ["add", "removed.txt"]);
2432+
yield* git(cwd, ["commit", "-m", "add removable file"]);
2433+
yield* git(cwd, ["rm", "--cached", "removed.txt"]);
2434+
if (stagedCopy) {
2435+
yield* writeTextFile(cwd, "copy.txt", "remove me\n");
2436+
yield* git(cwd, ["add", "copy.txt"]);
2437+
}
24292438

2430-
const preview = yield* driver.getReviewDiffPreview({ cwd, ignoreWhitespace: false });
2431-
const diff = preview.sources.find((source) => source.kind === "working-tree")?.diff ?? "";
2439+
const preview = yield* driver.getReviewDiffPreview({ cwd, ignoreWhitespace: false });
2440+
const diff = preview.sources.find((source) => source.kind === "working-tree")?.diff ?? "";
24322441

2433-
assert.include(diff, "deleted file mode");
2434-
assert.include(diff, "-remove me");
2435-
assert.notInclude(diff, "new file mode");
2436-
}),
2442+
for (const text of expected) assert.include(diff, text);
2443+
assert.notInclude(diff, "new file mode");
2444+
}),
24372445
);
24382446

24392447
it.effect.each([false, true])(

‎apps/server/src/vcs/GitVcsDriverCore.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2984,7 +2984,16 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
29842984
runGitStdoutWithOptions(
29852985
"GitVcsDriver.readUnifiedWorkingTreeReviewDiff.stagedDeletions",
29862986
cwd,
2987-
["diff", "--cached", "--name-only", "--diff-filter=D", "-z", "HEAD", "--"],
2987+
[
2988+
"diff",
2989+
"--cached",
2990+
"--no-renames",
2991+
"--name-only",
2992+
"--diff-filter=D",
2993+
"-z",
2994+
"HEAD",
2995+
"--",
2996+
],
29882997
{ allowNonZeroExit: true, maxOutputBytes: REVIEW_METADATA_MAX_OUTPUT_BYTES },
29892998
),
29902999
runGitStdout("GitVcsDriver.readUnifiedWorkingTreeReviewDiff.indexPath", cwd, [

0 commit comments

Comments
 (0)