The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 18:30 UTC
fix(server): keep repository identity for roots whose name ends in a space (#35767)
Julius Marminge committed
Nov 12, 2026 at 17:48 UTC
ad1c46ba42baa613f240b51af1b7b42beb6941a1
2 files changed
+28
-26
apps/server/src/project/RepositoryIdentityResolver.test.ts
+25
-22
@@ -111,31 +111,34 @@ it.layer(NodeServices.layer)("RepositoryIdentityResolverLive", (it) => {
111
}).pipe(Effect.provide(RepositoryIdentityResolver.layer)),
112
);
113
114
- it.effect("returns the git top-level root path when resolving from a nested workspace", () =>
115
- Effect.gen(function* () {
116
- const fileSystem = yield* FileSystem.FileSystem;
117
- const path = yield* Path.Path;
118
- const repoRoot = yield* fileSystem.makeTempDirectoryScoped({
119
- prefix: "t3-repository-identity-nested-root-test-",
120
- });
121
- const nestedWorkspace = path.join(repoRoot, "packages", "web");
114
+ it.effect.each(["repo", "repo "] as const)(
115
+ "returns the git top-level root path when resolving from a nested workspace in %j",
116
+ (rootName) =>
117
+ Effect.gen(function* () {
118
+ const fileSystem = yield* FileSystem.FileSystem;
119
+ const path = yield* Path.Path;
120
+ const tempDir = yield* fileSystem.makeTempDirectoryScoped({
121
+ prefix: "t3-repository-identity-nested-root-test-",
122
+ });
123
+ const repoRoot = path.join(tempDir, rootName);
124
+ const nestedWorkspace = path.join(repoRoot, "packages", "web");
125
123
- yield* fileSystem.makeDirectory(nestedWorkspace, { recursive: true });
124
- yield* git(repoRoot, ["init"]);
125
- yield* git(repoRoot, ["remote", "add", "origin", "git@github.com:T3Tools/t3code.git"]);
126
+ yield* fileSystem.makeDirectory(nestedWorkspace, { recursive: true });
127
+ yield* git(repoRoot, ["init"]);
128
+ yield* git(repoRoot, ["remote", "add", "origin", "git@github.com:T3Tools/t3code.git"]);
129
127
- const resolver = yield* RepositoryIdentityResolver.RepositoryIdentityResolver;
128
- const identity = yield* resolver.resolve(nestedWorkspace);
129
- const resolvedIdentityRoot =
130
- identity?.rootPath === undefined ? "" : NodeFS.realpathSync.native(identity.rootPath);
131
- const resolvedRepoRoot = NodeFS.realpathSync.native(repoRoot);
130
+ const resolver = yield* RepositoryIdentityResolver.RepositoryIdentityResolver;
131
+ const identity = yield* resolver.resolve(nestedWorkspace);
132
+ const resolvedIdentityRoot =
133
+ identity?.rootPath === undefined ? "" : NodeFS.realpathSync.native(identity.rootPath);
134
+ const resolvedRepoRoot = NodeFS.realpathSync.native(repoRoot);
135
133
- expect(identity).not.toBeNull();
134
- expect(identity?.canonicalKey).toBe("github.com/t3tools/t3code");
135
- expect(normalizeResolvedPath(resolvedIdentityRoot)).toBe(
136
- normalizeResolvedPath(resolvedRepoRoot),
137
- );
138
- }).pipe(Effect.provide(RepositoryIdentityResolver.layer)),
136
+ expect(identity).not.toBeNull();
137
+ expect(identity?.canonicalKey).toBe("github.com/t3tools/t3code");
138
+ expect(normalizeResolvedPath(resolvedIdentityRoot)).toBe(
139
+ normalizeResolvedPath(resolvedRepoRoot),
140
+ );
141
+ }).pipe(Effect.provide(RepositoryIdentityResolver.layer)),
142
);
143
144
it.effect.each(["bare clone", "dot-bare"] as const)(
apps/server/src/project/RepositoryIdentityResolver.ts
+3
-4
@@ -180,7 +180,8 @@ const resolveRepositoryIdentityCacheKey = Effect.fn("RepositoryIdentityResolver.
180
return null;
181
}
182
if (topLevelResult.value.code === 0) {
183
- const rootPath = topLevelResult.value.stdout.trim();
183
+ // Paths may end in spaces, so strip only git's line terminator.
184
+ const rootPath = topLevelResult.value.stdout.replace(/\r?\n$/, "");
185
return rootPath.length > 0
186
? new RepositoryIdentityCacheKey({ rootPath, isBare: false })
187
: null;
@@ -224,9 +225,7 @@ const resolveRepositoryIdentityCacheKey = Effect.fn("RepositoryIdentityResolver.
225
if (bareResult._tag === "None" || bareResult.value.timedOut) return null;
226
if (bareResult.value.code !== 0) continue;
227
227
- const [isBare, rootPath = ""] = bareResult.value.stdout
228
- .split("\n")
229
- .map((line) => line.trim());
228
+ const [isBare, rootPath = ""] = bareResult.value.stdout.split(/\r?\n/);
229
// A checkout's .git directory contains remotes but is not a project root.
230
return isBare === "true" && rootPath.length > 0
231
? new RepositoryIdentityCacheKey({ rootPath, isBare: true })