Skip to content
Closed
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
20 changes: 20 additions & 0 deletions apps/server/src/storageCleanup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2450,6 +2450,26 @@ describe("storage cleanup reports and local file policies", () => {
}),
),
);
it.live("keeps a thread's recreated worktree folder that has no .git", () =>
runCleanupTest(
Effect.gen(function* () {
const fixture = yield* cleanupFixture();
yield* fixture.command(fixture.repo, ["worktree", "remove", fixture.worktree]);
yield* fixture.fs.makeDirectory(`${fixture.worktree}/node_modules`, { recursive: true });
yield* fixture.fs.writeFileString(`${fixture.worktree}/yarn.lock`, "# lockfile\n");
expect((yield* fixture.service.runNow).entries).toEqual([
expect.objectContaining({
path: fixture.worktree,
outcome: "kept",
reason: "Not a linked worktree",
}),
]);
expect(yield* fixture.fs.readFileString(`${fixture.worktree}/yarn.lock`)).toBe(
"# lockfile\n",
);
}),
),
);
it.live.each([
["any-local-files", ".env", "kept"],
["uncommitted-changes", ".env", "removed"],
Expand Down
3 changes: 2 additions & 1 deletion apps/server/src/storageCleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,8 @@ const make = Effect.gen(function* () {
return "worktree is a symbolic link";
if (!roots.some((root) => inside(root, realPath)))
return "outside the managed worktree folder";
if ((yield* fs.stat(path.join(worktreePath, ".git"))).type !== "File")
const gitPath = path.join(worktreePath, ".git");
if (!(yield* fs.exists(gitPath)) || (yield* fs.stat(gitPath)).type !== "File")
return "not a linked worktree";
return null;
});
Expand Down
Loading