Skip to content

Commit cf5e6d3

Browse files
only21milclaude
andauthored
fix(server): selected-file commits stop when the index reset fails (#28275)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 3f69542 commit cf5e6d3

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5089,6 +5089,31 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
50895089
}),
50905090
);
50915091

5092+
it.effect("stops a selected-file commit when another process holds the index lock", () =>
5093+
Effect.gen(function* () {
5094+
const cwd = yield* makeTmpDir();
5095+
yield* initRepoWithCommit(cwd);
5096+
const head = yield* git(cwd, ["rev-parse", "HEAD"]);
5097+
yield* writeTextFile(cwd, "a.txt", "a\n");
5098+
yield* writeTextFile(cwd, "staged.txt", "staged\n");
5099+
yield* git(cwd, ["add", "staged.txt"]);
5100+
const lockPath = (yield* Path.Path).join(cwd, ".git", "index.lock");
5101+
yield* (yield* FileSystem.FileSystem).writeFileString(lockPath, "");
5102+
const { driver } = yield* makeDriverReleasingLock(
5103+
(args) => args.includes("reset"),
5104+
lockPath,
5105+
);
5106+
5107+
const error = yield* driver
5108+
.commit(cwd, "Add a", "", { stage: { filePaths: ["a.txt"] } })
5109+
.pipe(Effect.flip);
5110+
5111+
assert.equal(error.operation, "GitVcsDriver.commit.reset");
5112+
assert.equal(yield* git(cwd, ["rev-parse", "HEAD"]), head);
5113+
assert.equal(yield* git(cwd, ["diff", "--cached", "--name-only"]), "staged.txt");
5114+
}),
5115+
);
5116+
50925117
it.effect.each([
50935118
{ location: "root", ref: "refs/heads/MERGE_HEAD" },
50945119
{ location: "nested", ref: "refs/heads/MERGE_HEAD" },

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2450,9 +2450,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
24502450
"Cannot commit selected files during a merge. Commit all files to finish the merge.",
24512451
});
24522452
}
2453-
yield* runGit("GitVcsDriver.commit.reset", cwd, ["reset"]).pipe(
2454-
Effect.catchTags({ GitCommandError: () => Effect.void }),
2455-
);
2453+
yield* runGit("GitVcsDriver.commit.reset", cwd, ["reset", "--quiet"]);
24562454
}
24572455
yield* runGit(
24582456
"GitVcsDriver.commit.addSelected",

0 commit comments

Comments
 (0)