Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): removing a worktree no longer deletes what its junctions point to #17076

Closedsheehanmunim(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/17076/headopened View on GitHub

Showing 2 changed files with 99 additions and 0 deletions.

x
0 of 2 viewed, 2 left
39 additions and 0 deletionsapps/server/src/vcs/GitVcsDriverCore.test.tsModified
View file
@@ -3246,6 +3246,45 @@
+ it.effect("removes a worktree without deleting what its junctions point to", () =>
+ Effect.gen(function* () {
+ const cwd = yield* makeTmpDir();
+ const { initialBranch } = yield* initRepoWithCommit(cwd);
+ yield* writeTextFile(cwd, ".gitignore", "node_modules\n");
+ yield* writeTextFile(cwd, "packages/app/package.json", "{}\n");
+ yield* git(cwd, ["add", "."]);
+ yield* git(cwd, ["commit", "-m", "add app"]);
+ yield* writeTextFile(cwd, "node_modules/dep/index.js", "keep\n");
+ const fileSystem = yield* FileSystem.FileSystem;
+ const pathService = yield* Path.Path;
+ const worktreePath = pathService.join(yield* makeTmpDir("git-worktrees-"), "linked");
+ const driver = yield* GitVcsDriver.GitVcsDriver;
+ yield* driver.createWorktree({
+ cwd,
+ path: worktreePath,
+ refName: initialBranch,
+ newRefName: "feature/linked",
+ });
+ // Sharing the main checkout's install the usual Windows way: a junction
+ // there, a directory symlink elsewhere.
+ const shared = pathService.join(cwd, "node_modules");
+ NodeFS.symlinkSync(shared, pathService.join(worktreePath, "node_modules"), "junction");
+ NodeFS.symlinkSync(
+ shared,
+ pathService.join(worktreePath, "packages", "app", "node_modules"),