Skip to content

Commit d6ac53e

Browse files
fix(server): a project whose origin URL contains a space gets a repository identity (#35080)
1 parent 5bb4452 commit d6ac53e

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

‎apps/server/src/project/RepositoryIdentityResolver.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,23 @@ it.layer(NodeServices.layer)("RepositoryIdentityResolverLive", (it) => {
9494
}).pipe(Effect.provide(RepositoryIdentityResolver.layer)),
9595
);
9696

97+
it.effect("resolves a remote whose URL contains a space", () =>
98+
Effect.gen(function* () {
99+
const fileSystem = yield* FileSystem.FileSystem;
100+
const cwd = yield* fileSystem.makeTempDirectoryScoped({
101+
prefix: "t3-repository-identity-spaced-url-test-",
102+
});
103+
104+
yield* git(cwd, ["init"]);
105+
yield* git(cwd, ["remote", "add", "origin", "ssh://[email protected]/team repos/app.git"]);
106+
107+
const resolver = yield* RepositoryIdentityResolver.RepositoryIdentityResolver;
108+
const identity = yield* resolver.resolve(cwd);
109+
expect(identity?.locator.remoteUrl).toBe("ssh://[email protected]/team repos/app.git");
110+
expect(identity?.locator.remoteName).toBe("origin");
111+
}).pipe(Effect.provide(RepositoryIdentityResolver.layer)),
112+
);
113+
97114
it.effect("returns the git top-level root path when resolving from a nested workspace", () =>
98115
Effect.gen(function* () {
99116
const fileSystem = yield* FileSystem.FileSystem;

‎apps/server/src/project/RepositoryIdentityResolver.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,10 @@ function isLocalRemoteUrl(url: string): boolean {
5050

5151
function parseRemoteFetchUrls(stdout: string): Map<string, string> {
5252
const remotes = new Map<string, string>();
53-
for (const line of stdout.split("\n")) {
54-
const trimmed = line.trim();
55-
if (trimmed.length === 0) continue;
53+
for (const line of stdout.split(/\r?\n/)) {
54+
// Git uses a tab before the URL and one space before the direction; both can occur in URLs.
5655
// Partial clones append the promisor filter, e.g. `(fetch) [blob:none]`.
57-
const match = /^(\S+)\s+(\S+)\s+\((fetch|push)\)(?:\s+\[[^\]]+\])?$/.exec(trimmed);
56+
const match = /^(\S+)\t(.+) \((fetch|push)\)(?:\s+\[[^\]]+\])?$/.exec(line);
5857
if (!match) continue;
5958
const [, remoteName = "", remoteUrl = "", direction = ""] = match;
6059
if (

0 commit comments

Comments
 (0)