Skip to content

Commit 73fba11

Browse files
committed
fix(server): preserve spaces in Git remote URLs
1 parent ca6416e commit 73fba11

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

‎apps/server/src/vcs/GitVcsDriverCore.test.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,6 +1794,31 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {
17941794
});
17951795

17961796
describe("remote operations", () => {
1797+
it.effect("ensureRemote preserves local remote URLs containing spaces", () =>
1798+
Effect.gen(function* () {
1799+
const cwd = yield* makeTmpDir();
1800+
const path = yield* Path.Path;
1801+
yield* initRepoWithCommit(cwd);
1802+
const driver = yield* GitVcsDriver.GitVcsDriver;
1803+
const existingUrl = path.join(cwd, "local remote (fetch).git");
1804+
const newUrl = path.join(cwd, "another remote.git");
1805+
yield* git(cwd, ["remote", "add", "origin", existingUrl]);
1806+
yield* git(cwd, ["remote", "set-url", "--push", "origin", newUrl]);
1807+
1808+
assert.equal(
1809+
yield* driver.ensureRemote({ cwd, preferredName: "origin", url: existingUrl }),
1810+
"origin",
1811+
);
1812+
assert.equal(
1813+
yield* driver.ensureRemote({ cwd, preferredName: "origin", url: newUrl }),
1814+
"origin-1",
1815+
);
1816+
assert.equal(yield* git(cwd, ["remote", "get-url", "origin"]), existingUrl);
1817+
assert.equal(yield* git(cwd, ["remote", "get-url", "origin-1"]), newUrl);
1818+
assert.equal(yield* git(cwd, ["remote", "get-url", "--push", "origin"]), newUrl);
1819+
}),
1820+
);
1821+
17971822
it.effect("ensureRemote reuses an existing remote across ssh/https transport variants", () =>
17981823
Effect.gen(function* () {
17991824
const cwd = yield* makeTmpDir();

‎apps/server/src/vcs/GitVcsDriverCore.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ function parseRemoteFetchUrls(stdout: string): Map<string, string> {
308308
for (const line of stdout.split("\n")) {
309309
const trimmed = line.trim();
310310
if (trimmed.length === 0) continue;
311-
const match = /^(\S+)\s+(\S+)\s+\((fetch|push)\)$/.exec(trimmed);
311+
const match = /^(\S+)\s+(.+)\s+\((fetch|push)\)$/.exec(trimmed);
312312
if (!match) continue;
313313
const [, remoteName = "", remoteUrl = "", direction = ""] = match;
314314
if (direction !== "fetch" || remoteName.length === 0 || remoteUrl.length === 0) {

0 commit comments

Comments
 (0)