Skip to content

Commit 1fb8202

Browse files
committed
fix(server): parse the exact Git remote field separators
1 parent 73fba11 commit 1fb8202

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,7 +1800,7 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {
18001800
const path = yield* Path.Path;
18011801
yield* initRepoWithCommit(cwd);
18021802
const driver = yield* GitVcsDriver.GitVcsDriver;
1803-
const existingUrl = path.join(cwd, "local remote (fetch).git");
1803+
const existingUrl = " local remote (fetch).git ";
18041804
const newUrl = path.join(cwd, "another remote.git");
18051805
yield* git(cwd, ["remote", "add", "origin", existingUrl]);
18061806
yield* git(cwd, ["remote", "set-url", "--push", "origin", newUrl]);
@@ -1813,7 +1813,10 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {
18131813
yield* driver.ensureRemote({ cwd, preferredName: "origin", url: newUrl }),
18141814
"origin-1",
18151815
);
1816-
assert.equal(yield* git(cwd, ["remote", "get-url", "origin"]), existingUrl);
1816+
assert.equal(
1817+
yield* git(cwd, ["config", "--null", "--get-regexp", "^remote\\.origin\\.url$"]),
1818+
`remote.origin.url\n${existingUrl}\0`,
1819+
);
18171820
assert.equal(yield* git(cwd, ["remote", "get-url", "origin-1"]), newUrl);
18181821
assert.equal(yield* git(cwd, ["remote", "get-url", "--push", "origin"]), newUrl);
18191822
}),

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,7 @@ function sanitizeRemoteName(value: string): string {
306306
function parseRemoteFetchUrls(stdout: string): Map<string, string> {
307307
const remotes = new Map<string, string>();
308308
for (const line of stdout.split("\n")) {
309-
const trimmed = line.trim();
310-
if (trimmed.length === 0) continue;
311-
const match = /^(\S+)\s+(.+)\s+\((fetch|push)\)$/.exec(trimmed);
309+
const match = /^(\S+)\t(.+) \((fetch|push)\)$/.exec(line);
312310
if (!match) continue;
313311
const [, remoteName = "", remoteUrl = "", direction = ""] = match;
314312
if (direction !== "fetch" || remoteName.length === 0 || remoteUrl.length === 0) {

0 commit comments

Comments
 (0)