@devries-cameron20 / t3code Mirror · read-only / commits / a195ba0809
Fork 0

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 23, 01:45 UTC

fix(server): recognize partial-clone remote annotations (#16316)

Co-authored-by: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Maxwell Young committed Oct 20, 2026 at 10:13 UTC a195ba0809b5c1f16fad8119f3b961119924d1b2
10 files changed +100 -6
apps/server/src/project/RepositoryIdentityResolver.test.ts
+24
@@ -203,6 +203,30 @@ it.layer(NodeServices.layer)("RepositoryIdentityResolverLive", (it) => {
203 }).pipe(Effect.provide(RepositoryIdentityResolver.layer)),
204 );
205
206 + it.effect("resolves the fetch remote of a partial clone", () =>
207 + Effect.gen(function* () {
208 + const fileSystem = yield* FileSystem.FileSystem;
209 + const cwd = yield* fileSystem.makeTempDirectoryScoped({
210 + prefix: "t3-repository-identity-partial-clone-test-",
211 + });
212 +
213 + yield* git(cwd, ["init"]);
214 + yield* git(cwd, ["remote", "add", "origin", "git@github.com:T3Tools/t3code.git"]);
215 + yield* git(cwd, ["remote", "set-url", "--push", "origin", "git@github.com:T3Tools/push.git"]);
216 + yield* git(cwd, ["config", "remote.origin.promisor", "true"]);
217 + yield* git(cwd, ["config", "remote.origin.partialclonefilter", "blob:none"]);
218 +
219 + const remotes = yield* git(cwd, ["remote", "-v"]);
220 + expect(remotes.stdout).toContain("(fetch) [blob:none]");
221 +
222 + const resolver = yield* RepositoryIdentityResolver.RepositoryIdentityResolver;
223 + const identity = yield* resolver.resolve(cwd);
224 + expect(identity?.canonicalKey).toBe("github.com/t3tools/t3code");
225 + expect(identity?.locator.remoteUrl).toBe("git@github.com:T3Tools/t3code.git");
226 + expect(identity?.locator.remoteName).toBe("origin");
227 + }).pipe(Effect.provide(RepositoryIdentityResolver.layer)),
228 + );
229 +
230 it.effect("returns the git top-level root path when resolving from a nested workspace", () =>
231 Effect.gen(function* () {
232 const fileSystem = yield* FileSystem.FileSystem;
apps/server/src/project/RepositoryIdentityResolver.ts
+2 -1
@@ -58,7 +58,8 @@ function parseRemoteFetchUrls(stdout: string): Map<string, string> {
58 for (const line of stdout.split("\n")) {
59 const trimmed = line.trim();
60 if (trimmed.length === 0) continue;
61 - const match = /^(\S+)\s+(\S+)\s+\((fetch|push)\)$/.exec(trimmed);
61 + // Partial clones append the promisor filter, e.g. `(fetch) [blob:none]`.
62 + const match = /^(\S+)\s+(\S+)\s+\((fetch|push)\)(?:\s+\[[^\]]+\])?$/.exec(trimmed);
63 if (!match) continue;
64 const [, remoteName = "", remoteUrl = "", direction = ""] = match;
65 if (
apps/server/src/vcs/GitVcsDriver.test.ts
+32
@@ -9,6 +9,7 @@ import * as Fiber from "effect/Fiber";
9 import * as TestClock from "effect/testing/TestClock";
10 import * as FileSystem from "effect/FileSystem";
11 import * as Layer from "effect/Layer";
12 +import * as Option from "effect/Option";
13 import * as Path from "effect/Path";
14 import * as PlatformError from "effect/PlatformError";
15 import { ChildProcessSpawner } from "effect/process";
@@ -97,6 +98,37 @@ runVcsDriverContractSuite<GitVcsDriver.GitVcsDriver, GitContractError>({
98 },
99 });
100
101 +it.effect("lists the fetch and push URLs of a partial clone remote", () =>
102 + Effect.gen(function* () {
103 + const fileSystem = yield* FileSystem.FileSystem;
104 + const cwd = yield* fileSystem.makeTempDirectoryScoped({
105 + prefix: "t3-partial-clone-remotes-",
106 + });
107 + const driver = yield* GitVcsDriver.makeVcsDriverShape();
108 + yield* runGit(cwd, ["init"]);
109 + yield* runGit(cwd, ["remote", "add", "origin", "https://github.com/pingdotgg/t3code.git"]);
110 + yield* runGit(cwd, [
111 + "remote",
112 + "set-url",
113 + "--push",
114 + "origin",
115 + "git@github.com:octocat/t3code.git",
116 + ]);
117 + yield* runGit(cwd, ["config", "remote.origin.promisor", "true"]);
118 + yield* runGit(cwd, ["config", "remote.origin.partialclonefilter", "blob:none"]);
119 +
120 + const result = yield* driver.listRemotes(cwd);
121 + assert.deepEqual(result.remotes, [
122 + {
123 + name: "origin",
124 + url: "https://github.com/pingdotgg/t3code.git",
125 + pushUrl: Option.some("git@github.com:octocat/t3code.git"),
126 + isPrimary: true,
127 + },
128 + ]);
129 + }).pipe(Effect.scoped, Effect.provide(layerGitContract)),
130 +);
131 +
132 const makeCheckpointFixture = Effect.fn("makeCheckpointFixture")(function* (
133 driver: Effect.Success<ReturnType<typeof GitVcsDriver.makeVcsDriverShape>>,
134 cwd: string,
apps/server/src/vcs/GitVcsDriver.ts
+2 -1
@@ -466,7 +466,8 @@ function parseGitRemoteVerboseOutput(
466 continue;
467 }
468
469 - const match = /^(\S+)\s+(\S+)\s+\((fetch|push)\)$/.exec(trimmed);
469 + // Partial clones append the promisor filter, e.g. `(fetch) [blob:none]`.
470 + const match = /^(\S+)\s+(\S+)\s+\((fetch|push)\)(?:\s+\[[^\]]+\])?$/.exec(trimmed);
471 if (!match) {
472 continue;
473 }
apps/server/src/vcs/GitVcsDriverCore.test.ts
+24
@@ -4054,6 +4054,30 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
4054 });
4055
4056 describe("remote operations", () => {
4057 + it.effect("ensureRemote reuses a partial clone remote and avoids its name", () =>
4058 + Effect.gen(function* () {
4059 + const cwd = yield* makeTmpDir();
4060 + yield* git(cwd, ["init"]);
4061 + yield* git(cwd, ["remote", "add", "origin", "https://github.com/pingdotgg/t3code.git"]);
4062 + yield* git(cwd, ["config", "remote.origin.promisor", "true"]);
4063 + yield* git(cwd, ["config", "remote.origin.partialclonefilter", "blob:none"]);
4064 + const driver = yield* GitVcsDriver.GitVcsDriver;
4065 +
4066 + const reused = yield* driver.ensureRemote({
4067 + cwd,
4068 + preferredName: "origin",
4069 + url: "git@github.com:pingdotgg/t3code.git",
4070 + });
4071 + assert.equal(reused, "origin");
4072 + const added = yield* driver.ensureRemote({
4073 + cwd,
4074 + preferredName: "origin",
4075 + url: "https://github.com/another-owner/t3code.git",
4076 + });
4077 + assert.equal(added, "origin-1");
4078 + }),
4079 + );
4080 +
4081 it.effect("explains a real fetch failure for a missing local remote", () =>
4082 Effect.gen(function* () {
4083 const cwd = yield* makeTmpDir();
apps/server/src/vcs/GitVcsDriverCore.ts
+2 -1
@@ -334,7 +334,8 @@ function parseRemoteFetchUrls(stdout: string): Map<string, string> {
334 for (const line of stdout.split("\n")) {
335 const trimmed = line.trim();
336 if (trimmed.length === 0) continue;
337 - const match = /^(\S+)\s+(\S+)\s+\((fetch|push)\)$/.exec(trimmed);
337 + // Partial clones append the promisor filter, e.g. `(fetch) [blob:none]`.
338 + const match = /^(\S+)\s+(\S+)\s+\((fetch|push)\)(?:\s+\[[^\]]+\])?$/.exec(trimmed);
339 if (!match) continue;
340 const [, remoteName = "", remoteUrl = "", direction = ""] = match;
341 if (direction !== "fetch" || remoteName.length === 0 || remoteUrl.length === 0) {
packages/source-control-forgejo/src/server/ForgejoCli.ts
+4 -1
@@ -515,7 +515,10 @@ export const make = Effect.gen(function* () {
515 const matchingUrls = [
516 ...new Set(
517 result.stdout.split("\n").flatMap((line) => {
518 - const url = /^\S+\s+(https?:\/\/\S+)\s+\(fetch\)$/.exec(line.trim())?.[1];
518 + // Partial clones append the promisor filter, e.g. `(fetch) [blob:none]`.
519 + const url = /^\S+\s+(https?:\/\/\S+)\s+\(fetch\)(?:\s+\[[^\]]+\])?$/.exec(
520 + line.trim(),
521 + )?.[1];
522 return url && parseForgejoRemote(url)?.host === input.host?.toLowerCase()
523 ? [url]
524 : [];
packages/source-control-forgejo/src/server/ForgejoSourceControlProvider.test.ts
+3 -1
@@ -1046,7 +1046,9 @@ it.effect("prefers fj for HTTP and ported SSH aliases on root servers", () => {
1046 input.cwd === "/no-remotes"
1047 ? processOutput("", { exitCode: ChildProcessSpawner.ExitCode(2) })
1048 : processOutput(
1049 - `${input.cwd === "/upstream-only" ? "upstream" : "origin"}\thttp://forgejo.local:3000/maria/project.git (fetch)\nother\thttp://forgejo.local:3000/maria/other.git (fetch)\nunrelated\thttp://other.local:3000/maria/project.git (fetch)`,
1049 + input.cwd === "/upstream-only"
1050 + ? "upstream\thttp://forgejo.local:3000/maria/project.git (fetch) [blob:none]\nother\thttp://forgejo.local:3000/maria/other.git (fetch) [blob:none]\nunrelated\thttp://other.local:3000/maria/project.git (fetch) [blob:none]"
1051 + : "origin\thttp://forgejo.local:3000/maria/project.git (fetch)\nother\thttp://forgejo.local:3000/maria/other.git (fetch)\nunrelated\thttp://other.local:3000/maria/project.git (fetch)",
1052 ),
1053 );
1054 assert.strictEqual(input.command, "fj");
packages/source-control-github/src/server/gitHubRepositoryResolution.test.ts
+5
@@ -31,6 +31,11 @@ describe("selectGitHubBaseRepository", () => {
31 select({ remotes: fork, resolved: "remote.origin.gh-resolved acme/other" }),
32 { owner: "acme", name: "other" },
33 );
34 + const partialClone = fork.replaceAll("(fetch)", "(fetch) [blob:none]");
35 + assert.deepStrictEqual(
36 + select({ remotes: partialClone, resolved: "remote.origin.gh-resolved base" }),
37 + { owner: "me", name: "web" },
38 + );
39 assert.deepStrictEqual(
40 select({
41 remotes: remotes(
packages/source-control-github/src/server/gitHubRepositoryResolution.ts
+2 -1
@@ -13,9 +13,10 @@ export interface GitHubRepositoryLocator {
13 export function parseFetchRemotes(
14 remotes: string,
15 ): ReadonlyArray<{ readonly name: string; readonly url: string }> {
16 + // Partial clones append the promisor filter, e.g. `(fetch) [blob:none]`.
17 return remotes
18 .split("\n")
18 - .map((line) => /^(\S+)\s+(\S+)\s+\(fetch\)$/u.exec(line.trim()))
19 + .map((line) => /^(\S+)\s+(\S+)\s+\(fetch\)(?:\s+\[[^\]]+\])?$/u.exec(line.trim()))
20 .filter((match): match is RegExpExecArray => match !== null)
21 .map((match) => ({ name: match[1]!, url: match[2]! }));
22 }