Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions apps/server/src/vcs/GitVcsDriverCore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4824,6 +4824,31 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
}),
);

it.effect("stops a selected-file commit when another process holds the index lock", () =>
Effect.gen(function* () {
const cwd = yield* makeTmpDir();
yield* initRepoWithCommit(cwd);
const head = yield* git(cwd, ["rev-parse", "HEAD"]);
yield* writeTextFile(cwd, "a.txt", "a\n");
yield* writeTextFile(cwd, "staged.txt", "staged\n");
yield* git(cwd, ["add", "staged.txt"]);
const lockPath = (yield* Path.Path).join(cwd, ".git", "index.lock");
yield* (yield* FileSystem.FileSystem).writeFileString(lockPath, "");
const { driver } = yield* makeDriverReleasingLock(
(args) => args.includes("reset"),
lockPath,
);

const error = yield* driver
.commit(cwd, "Add a", "", { stage: { filePaths: ["a.txt"] } })
.pipe(Effect.flip);

assert.equal(error.operation, "GitVcsDriver.commit.reset");
assert.equal(yield* git(cwd, ["rev-parse", "HEAD"]), head);
assert.equal(yield* git(cwd, ["diff", "--cached", "--name-only"]), "staged.txt");
}),
);

it.effect.each([
{ location: "root", ref: "refs/heads/MERGE_HEAD" },
{ location: "nested", ref: "refs/heads/MERGE_HEAD" },
Expand Down
4 changes: 1 addition & 3 deletions apps/server/src/vcs/GitVcsDriverCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2421,9 +2421,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
"Cannot commit selected files during a merge. Commit all files to finish the merge.",
});
}
yield* runGit("GitVcsDriver.commit.reset", cwd, ["reset"]).pipe(
Effect.catchTags({ GitCommandError: () => Effect.void }),
);
yield* runGit("GitVcsDriver.commit.reset", cwd, ["reset"]);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}
yield* runGit(
"GitVcsDriver.commit.addSelected",
Expand Down
Loading