Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): removing a worktree on Windows no longer leaves junctions behind #15833

MergedSunkenInTime(GitHub profile, opens in a new tab)merged 12 commits intomain fromrefs/pull/15833/headmerged by juliusmarminge View on GitHub

Showing 3 changed files with 146 additions and 1 deletion.

x
0 of 3 viewed, 3 left
78 additions and 0 deletionsapps/server/src/vcs/GitVcsDriverCore.test.tsModified
View file
@@ -4019,6 +4019,57 @@
+ it.effect.each([false, true])(
+ "cleans up links left by successful worktree removal, preserving ordinary files: %s",
+ (keepFile) =>
+ Effect.gen(function* () {
+ const cwd = yield* makeTmpDir();
+ const fileSystem = yield* FileSystem.FileSystem;
+ const pathService = yield* Path.Path;
+ const outside = yield* makeTmpDir("git-worktree-link-target-");
+ yield* writeTextFile(outside, "keep.txt", "external target\n");
+ const worktreePath = pathService.join(cwd, "leftover");
+ const nested = pathService.join(worktreePath, "node_modules");
+ yield* fileSystem.makeDirectory(nested, { recursive: true });
+ yield* fileSystem.makeDirectory(pathService.join(worktreePath, "empty"));
+ NodeFS.symlinkSync(outside, pathService.join(worktreePath, "linked"), "junction");
+ NodeFS.symlinkSync(outside, pathService.join(nested, "pkg"), "junction");
+ if (keepFile) {
+ yield* writeTextFile(worktreePath, "notes/draft.txt", "new work\n");
+ }
+​
+ // Git removes symlinks on Unix; simulate its successful Windows removal
+ // leaving junctions behind so the cleanup is exercised on every platform.
+ const delegate = yield* ChildProcessSpawner.ChildProcessSpawner;
+ const spawner = ChildProcessSpawner.make((command) =>
+ ChildProcess.isStandardCommand(command) &&
+ command.args.join(" ").includes("worktree remove")
+ ? Effect.succeed(makeSuccessfulHandle(""))