Skip to content

Commit e9137df

Browse files
saphidclaude
authored andcommitted
fix(server): Uncommitted review keeps a staged deletion that git pairs into a rename
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent cbd3e14 commit e9137df

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
@@ -2337,23 +2337,31 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
23372337
}),
23382338
);
23392339

2340-
it.effect("preserves a staged deletion when the removed path still exists", () =>
2341-
Effect.gen(function* () {
2342-
const cwd = yield* makeTmpDir();
2343-
yield* initRepoWithCommit(cwd);
2344-
const driver = yield* GitVcsDriver.GitVcsDriver;
2345-
yield* writeTextFile(cwd, "removed.txt", "remove me\n");
2346-
yield* git(cwd, ["add", "removed.txt"]);
2347-
yield* git(cwd, ["commit", "-m", "add removable file"]);
2348-
yield* git(cwd, ["rm", "--cached", "removed.txt"]);
2340+
it.effect.each([
2341+
{ stagedCopy: false, expected: ["deleted file mode", "-remove me"] },
2342+
{ stagedCopy: true, expected: ["rename from removed.txt", "rename to copy.txt"] },
2343+
])(
2344+
"preserves a staged deletion when the removed path still exists (staged copy: $stagedCopy)",
2345+
({ stagedCopy, expected }) =>
2346+
Effect.gen(function* () {
2347+
const cwd = yield* makeTmpDir();
2348+
yield* initRepoWithCommit(cwd);
2349+
const driver = yield* GitVcsDriver.GitVcsDriver;
2350+
yield* writeTextFile(cwd, "removed.txt", "remove me\n");
2351+
yield* git(cwd, ["add", "removed.txt"]);
2352+
yield* git(cwd, ["commit", "-m", "add removable file"]);
2353+
yield* git(cwd, ["rm", "--cached", "removed.txt"]);
2354+
if (stagedCopy) {
2355+
yield* writeTextFile(cwd, "copy.txt", "remove me\n");
2356+
yield* git(cwd, ["add", "copy.txt"]);
2357+
}
23492358

2350-
const preview = yield* driver.getReviewDiffPreview({ cwd, ignoreWhitespace: false });
2351-
const diff = preview.sources.find((source) => source.kind === "working-tree")?.diff ?? "";
2359+
const preview = yield* driver.getReviewDiffPreview({ cwd, ignoreWhitespace: false });
2360+
const diff = preview.sources.find((source) => source.kind === "working-tree")?.diff ?? "";
23522361

2353-
assert.include(diff, "deleted file mode");
2354-
assert.include(diff, "-remove me");
2355-
assert.notInclude(diff, "new file mode");
2356-
}),
2362+
for (const text of expected) assert.include(diff, text);
2363+
assert.notInclude(diff, "new file mode");
2364+
}),
23572365
);
23582366

23592367
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
@@ -2974,7 +2974,16 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
29742974
runGitStdoutWithOptions(
29752975
"GitVcsDriver.readUnifiedWorkingTreeReviewDiff.stagedDeletions",
29762976
cwd,
2977-
["diff", "--cached", "--name-only", "--diff-filter=D", "-z", "HEAD", "--"],
2977+
[
2978+
"diff",
2979+
"--cached",
2980+
"--no-renames",
2981+
"--name-only",
2982+
"--diff-filter=D",
2983+
"-z",
2984+
"HEAD",
2985+
"--",
2986+
],
29782987
{ allowNonZeroExit: true, maxOutputBytes: REVIEW_METADATA_MAX_OUTPUT_BYTES },
29792988
),
29802989
runGitStdout("GitVcsDriver.readUnifiedWorkingTreeReviewDiff.indexPath", cwd, [

0 commit comments

Comments
 (0)