Skip to content
Open
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
25 changes: 25 additions & 0 deletions apps/server/src/workspace/TaskFolders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,31 @@ it.live("resumes once an excluded dependency's worktree is replaced by a clone",
),
);

// Git writes a worktree's `.git` with the folder's case on disk, not the case the project was added with.
it.live("resumes a thread whose project path differs from disk only in letter case", () =>
withState((state) =>
Effect.gen(function* () {
const { fileSystem, path, tmp, repository } = yield* fixture;
const app = yield* repository("Developer/app");
const lib = yield* repository("Developer/lib");
const lower = (folder: string) =>
path.join(tmp, path.relative(tmp, folder).replace("Developer", "developer"));
// Only a case-insensitive volume, like macOS's default, has both spellings.
if (!(yield* fileSystem.exists(lower(app)))) return;
state.workspaceRoot = lower(app);
state.trackedFolders = tracked(lower(lib));
const { taskFolder } = yield* create("feature", [{ path: lower(lib) }]);

yield* (yield* TaskFolders.TaskFolders).restore({
taskFolder,
branch: "feature",
projectCommands: "permitted",
recreate: () => Effect.die("nothing is missing"),
});
}),
),
);

// A project whose `t3.json` lays its own folder out, with a marker file per command that ran.
const layoutProject = Effect.gen(function* () {
const { fileSystem, path, tmp, run, repository } = yield* fixture;
Expand Down
6 changes: 5 additions & 1 deletion apps/server/src/workspace/TaskFolders.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// @effect-diagnostics-next-line nodeBuiltinImport:off -- FileSystem.realPath is Node's JS realpath, which keeps the letter case it is given.
import * as NodeFSP from "node:fs/promises";

import {
GitCommandError,
isRuntimeModeAbove,
Expand Down Expand Up @@ -569,8 +572,9 @@ const make = Effect.gen(function* () {
// rename: a worktree linked to the repository, on the thread's branch. Null when it is.
/** The checkout's own Git directory when it is a worktree linked to its repository. */
const linkedGitDir = Effect.fnUntraced(function* (checkout: TaskFolderCheckout) {
// Git records the case on disk; native realpath corrects a project path typed in another case.
const real = (target: string) =>
fileSystem.realPath(target).pipe(Effect.orElseSucceed(() => target));
Effect.promise(() => NodeFSP.realpath(target).catch(() => target));
const resolved = yield* gitDirPointer(checkout.worktreePath);
if (
resolved === null ||
Expand Down
Loading