@devries-cameron20 / t3code Mirror · read-only / commits / 1b42b169a3
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, 22:15 UTC

fix(server): preserve spaces in Git remote URLs (#34324)

Lakshmi Tanmay committed Nov 12, 2026 at 04:52 UTC 1b42b169a332046fdcb50a573ef269f9b73b2358
4 files changed +109 -40
apps/server/src/vcs/GitVcsDriver.test.ts
+48 -29
@@ -102,35 +102,54 @@ runVcsDriverContractSuite<GitVcsDriver.GitVcsDriver, GitContractError>({
102 },
103 });
104
105 -it.effect("lists the fetch and push URLs of a partial clone remote", () =>
106 - Effect.gen(function* () {
107 - const fileSystem = yield* FileSystem.FileSystem;
108 - const cwd = yield* fileSystem.makeTempDirectoryScoped({
109 - prefix: "t3-partial-clone-remotes-",
110 - });
111 - const driver = yield* GitVcsDriver.makeVcsDriverShape();
112 - yield* runGit(cwd, ["init"]);
113 - yield* runGit(cwd, ["remote", "add", "origin", "https://github.com/pingdotgg/t3code.git"]);
114 - yield* runGit(cwd, [
115 - "remote",
116 - "set-url",
117 - "--push",
118 - "origin",
119 - "git@github.com:octocat/t3code.git",
120 - ]);
121 - yield* runGit(cwd, ["config", "remote.origin.promisor", "true"]);
122 - yield* runGit(cwd, ["config", "remote.origin.partialclonefilter", "blob:none"]);
123 -
124 - const result = yield* driver.listRemotes(cwd);
125 - assert.deepEqual(result.remotes, [
126 - {
127 - name: "origin",
128 - url: "https://github.com/pingdotgg/t3code.git",
129 - pushUrl: Option.some("git@github.com:octocat/t3code.git"),
130 - isPrimary: true,
131 - },
132 - ]);
133 - }).pipe(Effect.scoped, Effect.provide(layerGitContract)),
105 +it.effect.each([
106 + {
107 + fetchUrl: "https://github.com/pingdotgg/t3code.git",
108 + pushUrl: "git@github.com:octocat/t3code.git",
109 + lineEnding: "\n",
110 + },
111 + { fetchUrl: "../team repos/shared.git", pushUrl: "../team repos/push.git", lineEnding: "\n" },
112 + {
113 + fetchUrl: " ../team repos/shared (fetch) [blob:none].git ",
114 + pushUrl: "../team repos/push (push).git\t",
115 + lineEnding: "\r\n",
116 + },
117 +])(
118 + "lists the fetch and push URLs of a partial clone remote (%j)",
119 + ({ fetchUrl, pushUrl, lineEnding }) =>
120 + Effect.gen(function* () {
121 + const fileSystem = yield* FileSystem.FileSystem;
122 + const cwd = yield* fileSystem.makeTempDirectoryScoped({
123 + prefix: "t3-partial-clone-remotes-",
124 + });
125 + const process = yield* VcsProcess.VcsProcess;
126 + const driver = yield* GitVcsDriver.makeVcsDriverShape().pipe(
127 + Effect.provideService(VcsProcess.VcsProcess, {
128 + run: (input) =>
129 + process.run(input).pipe(
130 + Effect.map((result) => ({
131 + ...result,
132 + stdout: result.stdout.replace(/\r?\n/g, lineEnding),
133 + })),
134 + ),
135 + }),
136 + );
137 + yield* runGit(cwd, ["init"]);
138 + yield* runGit(cwd, ["remote", "add", "origin", fetchUrl]);
139 + yield* runGit(cwd, ["remote", "set-url", "--push", "origin", pushUrl]);
140 + yield* runGit(cwd, ["config", "remote.origin.promisor", "true"]);
141 + yield* runGit(cwd, ["config", "remote.origin.partialclonefilter", "blob:none"]);
142 +
143 + const result = yield* driver.listRemotes(cwd);
144 + assert.deepEqual(result.remotes, [
145 + {
146 + name: "origin",
147 + url: fetchUrl,
148 + pushUrl: Option.some(pushUrl),
149 + isPrimary: true,
150 + },
151 + ]);
152 + }).pipe(Effect.scoped, Effect.provide(layerGitContract)),
153 );
154
155 const makeCheckpointFixture = Effect.fn("makeCheckpointFixture")(function* (
apps/server/src/vcs/GitVcsDriver.ts
+3 -7
@@ -517,14 +517,10 @@ function parseGitRemoteVerboseOutput(
517 output: string,
518 ): Map<string, { url?: string; pushUrl?: string }> {
519 const remotes = new Map<string, { url?: string; pushUrl?: string }>();
520 - for (const line of output.split("\n")) {
521 - const trimmed = line.trim();
522 - if (trimmed.length === 0) {
523 - continue;
524 - }
525 -
520 + for (const line of output.split(/\r?\n/)) {
521 + // Git uses a tab before the URL and one space before the direction; both can occur in URLs.
522 // Partial clones append the promisor filter, e.g. `(fetch) [blob:none]`.
527 - const match = /^(\S+)\s+(\S+)\s+\((fetch|push)\)(?:\s+\[[^\]]+\])?$/.exec(trimmed);
523 + const match = /^(\S+)\t(.+) \((fetch|push)\)(?:\s+\[[^\]]+\])?$/.exec(line);
524 if (!match) {
525 continue;
526 }
apps/server/src/vcs/GitVcsDriverCore.test.ts
+55
@@ -5724,6 +5724,61 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
5724 }),
5725 );
5726
5727 + it.effect.each(["\n", "\r\n"])(
5728 + "ensureRemote preserves spaces in fetch URLs and reserves their names (%j)",
5729 + (lineEnding) =>
5730 + Effect.gen(function* () {
5731 + const cwd = yield* makeTmpDir();
5732 + const fetchUrl = " ../team repos/shared (fetch) [blob:none].git ";
5733 + const pushUrl = "../team repos/push (push).git";
5734 + yield* git(cwd, ["init"]);
5735 + yield* git(cwd, ["remote", "add", "origin", fetchUrl]);
5736 + yield* git(cwd, ["remote", "set-url", "--push", "origin", pushUrl]);
5737 + yield* git(cwd, ["config", "remote.origin.promisor", "true"]);
5738 + yield* git(cwd, ["config", "remote.origin.partialclonefilter", "blob:none"]);
5739 + const liveDriver = yield* GitVcsDriver.GitVcsDriver;
5740 + const listing = yield* liveDriver.execute({
5741 + cwd,
5742 + args: ["remote", "-v"],
5743 + operation: "test",
5744 + });
5745 + const delegate = yield* ChildProcessSpawner.ChildProcessSpawner;
5746 + const spawner = ChildProcessSpawner.make((command) =>
5747 + ChildProcess.isStandardCommand(command) &&
5748 + command.args[0] === "remote" &&
5749 + command.args[1] === "-v"
5750 + ? Effect.succeed(makeSuccessfulHandle(listing.stdout.replace(/\r?\n/g, lineEnding)))
5751 + : delegate.spawn(command),
5752 + );
5753 + const driver = yield* makeGitVcsDriverCore().pipe(
5754 + Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
5755 + Effect.provide(layerServerConfig),
5756 + );
5757 +
5758 + assert.equal(
5759 + yield* driver.ensureRemote({ cwd, preferredName: "origin", url: fetchUrl }),
5760 + "origin",
5761 + );
5762 + assert.equal(
5763 + yield* driver.ensureRemote({ cwd, preferredName: "origin", url: pushUrl }),
5764 + "origin-1",
5765 + );
5766 + const fetch = yield* liveDriver.execute({
5767 + cwd,
5768 + args: ["config", "--get", "remote.origin.url"],
5769 + operation: "test",
5770 + });
5771 + const push = yield* liveDriver.execute({
5772 + cwd,
5773 + args: ["config", "--get", "remote.origin.pushurl"],
5774 + operation: "test",
5775 + });
5776 + assert.equal(fetch.stdout, `${fetchUrl}\n`);
5777 + assert.equal(push.stdout, `${pushUrl}\n`);
5778 + assert.equal(yield* git(cwd, ["config", "--get", "remote.origin-1.url"]), pushUrl);
5779 + }),
5780 + );
5781 +
5782 it.effect("ensureRemote returns the remote a parallel call added for the same URL", () =>
5783 Effect.gen(function* () {
5784 const cwd = yield* makeTmpDir();
apps/server/src/vcs/GitVcsDriverCore.ts
+3 -4
@@ -353,11 +353,10 @@ function sanitizeRemoteName(value: string): string {
353
354 function parseRemoteFetchUrls(stdout: string): Map<string, string> {
355 const remotes = new Map<string, string>();
356 - for (const line of stdout.split("\n")) {
357 - const trimmed = line.trim();
358 - if (trimmed.length === 0) continue;
356 + for (const line of stdout.split(/\r?\n/)) {
357 + // Git uses a tab before the URL and one space before the direction; both can occur in URLs.
358 // Partial clones append the promisor filter, e.g. `(fetch) [blob:none]`.
360 - const match = /^(\S+)\s+(\S+)\s+\((fetch|push)\)(?:\s+\[[^\]]+\])?$/.exec(trimmed);
359 + const match = /^(\S+)\t(.+) \((fetch|push)\)(?:\s+\[[^\]]+\])?$/.exec(line);
360 if (!match) continue;
361 const [, remoteName = "", remoteUrl = "", direction = ""] = match;
362 if (direction !== "fetch" || remoteName.length === 0 || remoteUrl.length === 0) {