Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
33 changes: 30 additions & 3 deletions apps/server/src/vcs/GitVcsDriverCore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {
_tag: "GitCommandError",
operation: "GitVcsDriver.removeWorktree",
command: "git",
argumentCount: 3,
argumentCount: 5,
cwd,
});
assert.notProperty(error, "cause");
Expand Down Expand Up @@ -2883,6 +2883,34 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {
}),
);

it.effect("keeps a worktree whose untracked files status is configured to hide", () =>
Effect.gen(function* () {
const cwd = yield* makeTmpDir();
const { initialBranch } = yield* initRepoWithCommit(cwd);
const pathService = yield* Path.Path;
const worktreePath = pathService.join(yield* makeTmpDir("git-worktrees-"), "hidden");
const driver = yield* GitVcsDriver.GitVcsDriver;
yield* driver.createWorktree({
cwd,
path: worktreePath,
refName: initialBranch,
newRefName: "feature/hidden",
});
yield* git(cwd, ["config", "status.showUntrackedFiles", "no"]);
yield* writeTextFile(worktreePath, "notes.txt", "draft\n");
assert.equal(yield* git(worktreePath, ["status", "--porcelain"]), "");

const result = yield* Effect.result(driver.removeWorktree({ cwd, path: worktreePath }));

assert.isTrue(Result.isFailure(result));
const fileSystem = yield* FileSystem.FileSystem;
assert.equal(
yield* fileSystem.readFileString(pathService.join(worktreePath, "notes.txt")),
"draft\n",
);
}),
);

it.effect("allows worktree removal to run longer than the default command timeout", () =>
Effect.gen(function* () {
const delegate = yield* ChildProcessSpawner.ChildProcessSpawner;
Expand All @@ -2891,8 +2919,7 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {
Effect.gen(function* () {
if (
ChildProcess.isStandardCommand(command) &&
command.args[0] === "worktree" &&
command.args[1] === "remove"
command.args.join(" ").includes("worktree remove")
) {
yield* Deferred.succeed(removalStarted, undefined);
yield* Effect.sleep("31 seconds");
Expand Down
4 changes: 3 additions & 1 deletion apps/server/src/vcs/GitVcsDriverCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3649,7 +3649,9 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
const removeWorktree: GitVcsDriver.GitVcsDriver["Service"]["removeWorktree"] = Effect.fn(
"removeWorktree",
)(function* (input) {
const args = ["worktree", "remove"];
// Git refuses to remove a worktree with untracked files unless forced, but
// its check honors `status.showUntrackedFiles=no` and would delete them.
const args = ["-c", "status.showUntrackedFiles=normal", "worktree", "remove"];
if (input.force) {
args.push("--force");
}
Expand Down
Loading