The best way to control Claude Code, Codex and more from any computer or phone
fix(server): gh default remote lookup ignores an inherited GIT_DIR (#35764)
Julius Marminge committed
Nov 12, 2026 at 17:54 UTC
b8c74f5a13657714d698e2e84e19d81da93549ff
2 files changed
+33
-2
apps/server/src/project/RepositoryIdentityResolver.test.ts
+30
@@ -5,6 +5,7 @@ import { expect, it } from "@effect/vitest";
5
import * as Effect from "effect/Effect";
6
import * as FileSystem from "effect/FileSystem";
7
import * as Path from "effect/Path";
8
+import { vi } from "vite-plus/test";
9
10
import * as ProcessRunner from "../processRunner.ts";
11
import * as RepositoryIdentityResolver from "./RepositoryIdentityResolver.ts";
@@ -343,6 +344,35 @@ it.layer(NodeServices.layer)("RepositoryIdentityResolverLive", (it) => {
344
}).pipe(Effect.provide(RepositoryIdentityResolver.layer)),
345
);
346
347
+ it.effect("reads the project's gh default when the server inherited GIT_DIR", () =>
348
+ Effect.gen(function* () {
349
+ const fileSystem = yield* FileSystem.FileSystem;
350
+ const path = yield* Path.Path;
351
+ const cwd = yield* fileSystem.makeTempDirectoryScoped({
352
+ prefix: "t3-repository-identity-gh-default-git-dir-",
353
+ });
354
+ const other = yield* fileSystem.makeTempDirectoryScoped({
355
+ prefix: "t3-repository-identity-inherited-git-dir-",
356
+ });
357
+
358
+ yield* git(cwd, ["init"]);
359
+ yield* git(cwd, ["remote", "add", "origin", "git@github.com:julius/t3code-fork.git"]);
360
+ yield* git(cwd, ["remote", "add", "upstream", "git@github.com:T3Tools/t3code.git"]);
361
+ yield* git(cwd, ["config", "remote.origin.gh-resolved", "base"]);
362
+ yield* git(other, ["init"]);
363
+ yield* git(other, ["config", "remote.upstream.gh-resolved", "base"]);
364
+
365
+ vi.stubEnv("GIT_DIR", path.join(other, ".git"));
366
+ yield* Effect.addFinalizer(() => Effect.sync(() => vi.unstubAllEnvs()));
367
+
368
+ const resolver = yield* RepositoryIdentityResolver.RepositoryIdentityResolver;
369
+ const identity = yield* resolver.resolve(cwd);
370
+
371
+ expect(identity?.canonicalKey).toBe("github.com/julius/t3code-fork");
372
+ expect(identity?.locator.remoteName).toBe("origin");
373
+ }).pipe(Effect.provide(RepositoryIdentityResolver.layer)),
374
+ );
375
+
376
it.effect("uses the last remote path segment as the repository name for nested groups", () =>
377
Effect.gen(function* () {
378
const fileSystem = yield* FileSystem.FileSystem;
apps/server/src/project/RepositoryIdentityResolver.ts
+3
-2
@@ -241,11 +241,12 @@ const resolveRepositoryIdentityFromCacheKey = Effect.fn(
241
cacheKey: RepositoryIdentityCacheKey,
242
): Effect.fn.Return<RepositoryIdentity | null, never, ProcessRunner.ProcessRunner> {
243
const processRunner = yield* ProcessRunner.ProcessRunner;
244
+ const env = gitEnv(yield* HostProcess.Platform);
245
const remoteResult = yield* processRunner
246
.run({
247
command: "git",
248
args: ["-C", cacheKey.rootPath, ...(cacheKey.isBare ? ["--git-dir=."] : []), "remote", "-v"],
248
- env: gitEnv(yield* HostProcess.Platform),
249
+ env,
250
timeoutBehavior: "timedOutResult",
251
})
252
.pipe(Effect.option);
@@ -264,7 +265,7 @@ const resolveRepositoryIdentityFromCacheKey = Effect.fn(
265
"--get-regexp",
266
"^remote\\..*\\.gh-resolved$",
267
],
267
- env: explicitBareRepositoryEnv(process.env, yield* HostProcess.Platform),
268
+ env,
269
timeoutBehavior: "timedOutResult",
270
})
271
.pipe(Effect.option);