@devries-cameron20 / t3code Mirror · read-only / commits / 9b38039631
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 21, 12:15 UTC

fix(forgejo): prefer the deepest-mounted login when a root login also matches (#35916)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Nov 14, 2026 at 20:48 UTC 9b380396316ca8c414f0c884bfda8b3024bfac28
2 files changed +13 -1
packages/source-control-forgejo/src/server/ForgejoCli.ts
+8 -1
@@ -184,7 +184,7 @@ export function matchForgejoLogin(
184 requestedHost?: string,
185 hostOnly = false,
186 ) {
187 - const matches = [
187 + let matches = [
188 ...new Map(
189 logins
190 .filter((login) => {
@@ -204,6 +204,13 @@ export function matchForgejoLogin(
204 .map((login) => [login.name, login]),
205 ).values(),
206 ];
207 + if (!remote.ssh && remote.path) {
208 + // A root login matches every path on its host; the instance mounted deepest owns the remote.
209 + const depth = (login: (typeof matches)[number]) =>
210 + parseForgejoRemote(login.url)?.path.length ?? 0;
211 + const deepest = Math.max(...matches.map(depth));
212 + matches = matches.filter((login) => depth(login) === deepest);
213 + }
214 return matches.length === 1
215 ? matches[0]
216 : new Set(matches.map((login) => login.url)).size === 1
packages/source-control-forgejo/src/server/ForgejoSourceControlProvider.test.ts
+5
@@ -1524,6 +1524,11 @@ it.effect("does not choose a default Forgejo login across ambiguous SSH server p
1524 url: `http://forgejo.local:4000/${login.name}`,
1525 }));
1526 assert.isUndefined(ForgejoCli.matchForgejoLogin(mounted, hostOnly!, undefined, true));
1527 + const rootAndMounted = [logins[1]!, { ...logins[0]!, url: "http://forgejo.local:4000/gitea" }];
1528 + const underMount = ForgejoCli.parseForgejoRemote(
1529 + "http://forgejo.local:4000/gitea/maria/project.git",
1530 + );
1531 + assert.strictEqual(ForgejoCli.matchForgejoLogin(rootAndMounted, underMount!)?.name, "one");
1532 }),
1533 );
1534