Skip to content

Commit 7890d40

Browse files
test(server): restore worktree short-name regression coverage
1 parent 8e5f073 commit 7890d40

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3838,6 +3838,33 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
38383838
}),
38393839
);
38403840

3841+
it.effect("leaves a folder alone that only shares the worktree's short name", () =>
3842+
Effect.gen(function* () {
3843+
const cwd = yield* makeTmpDir();
3844+
const { initialBranch } = yield* initRepoWithCommit(cwd);
3845+
const pathService = yield* Path.Path;
3846+
const fileSystem = yield* FileSystem.FileSystem;
3847+
const driver = yield* GitVcsDriver.GitVcsDriver;
3848+
const worktreePath = pathService.join(yield* makeTmpDir("git-worktrees-"), "short");
3849+
yield* driver.createWorktree({
3850+
cwd,
3851+
path: worktreePath,
3852+
refName: initialBranch,
3853+
newRefName: "feature/short",
3854+
});
3855+
// Unrelated to the worktree, but resolving "short" against cwd lands here.
3856+
const outside = yield* makeTmpDir("git-worktree-link-target-");
3857+
const unrelated = pathService.join(cwd, "short");
3858+
NodeFS.mkdirSync(unrelated);
3859+
NodeFS.symlinkSync(outside, pathService.join(unrelated, "linked"), "junction");
3860+
3861+
yield* Effect.result(driver.removeWorktree({ cwd, path: "short" }));
3862+
3863+
assert.isTrue(NodeFS.lstatSync(pathService.join(unrelated, "linked")).isSymbolicLink());
3864+
assert.equal(yield* fileSystem.exists(worktreePath), true);
3865+
}),
3866+
);
3867+
38413868
it.effect("allows worktree removal to run longer than the default command timeout", () =>
38423869
Effect.gen(function* () {
38433870
const delegate = yield* ChildProcessSpawner.ChildProcessSpawner;

0 commit comments

Comments
 (0)