@devries-cameron20 / t3code Mirror · read-only / commits / 8689c7a4f5
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 22, 12:00 UTC

fix(server): onboarding reads a remote url on its section header line (#23747)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>

Wesley Smits committed Oct 30, 2026 at 23:58 UTC 8689c7a4f5e61eec98b7ac7dfc91eea6ff7daf49
2 files changed +21 -6
packages/shared/src/git.test.ts
+15
@@ -113,6 +113,21 @@ describe("parseOriginUrlFromGitConfig", () => {
113 ).toBe("https://github.com/acme/repo.git");
114 });
115
116 + it("reads settings on the remote header line", () => {
117 + const upstream = '\n[remote "upstream"]\n\turl = https://github.com/other/source.git\n';
118 + expect(
119 + parseOriginUrlFromGitConfig(`[remote "origin"] url = git@github.com:a/b.git${upstream}`),
120 + ).toBe("git@github.com:a/b.git");
121 + expect(parseOriginUrlFromGitConfig("[remote.Origin]url=git@github.com:a/b.git\n")).toBe(
122 + "git@github.com:a/b.git",
123 + );
124 + expect(
125 + parseOriginUrlFromGitConfig(
126 + `[remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/*\n\turl = git@github.com:a/b.git${upstream}`,
127 + ),
128 + ).toBe("git@github.com:a/b.git");
129 + });
130 +
131 it("falls back to the first remote when there is no origin", () => {
132 const config = [
133 '[remote "upstream"]',
packages/shared/src/git.ts
+6 -6
@@ -214,15 +214,15 @@ export function parseOriginUrlFromGitConfig(configText: string): string | null {
214 let firstRemoteUrl: string | null = null;
215 const joined = configText.replace(/\\\r?\n[ \t]*/g, "");
216 for (const rawLine of joined.split(/\r?\n/)) {
217 - const line = rawLine.trim();
217 + let line = rawLine.trim();
218 if (line.length === 0 || line.startsWith("#") || line.startsWith(";")) continue;
219 - // Git preserves case in quoted remote subsections but lowercases legacy dotted ones.
220 - const header = /^\[\s*remote(?:\s+"([^"]+)"|\.([^\]\s]+))\s*\](?:\s*[#;].*)?$/i.exec(line);
219 + // Git preserves case in quoted remote subsections but lowercases legacy dotted ones,
220 + // and accepts the first setting on the section header's own line.
221 + const header = /^\[\s*remote(?:\s+"([^"]+)"|\.([^\]\s]+))\s*\](.*)$/i.exec(line);
222 if (header) {
223 section = header[1] ?? header[2]?.toLowerCase() ?? null;
223 - continue;
224 - }
225 - if (line.startsWith("[")) {
224 + line = header[3]!.trim();
225 + } else if (line.startsWith("[")) {
226 section = null;
227 continue;
228 }