Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions packages/client-runtime/src/operations/projects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,24 @@ describe("add project shared logic", () => {
sshUrl: "ssh://git@forgejo.example.test:2222/owner/repo.git",
}),
).toBe("https://forgejo.example.test:8443/owner/repo.git");
expect(
getDefaultCloneUrl({
provider: "gitlab",
// The lookup returns GitLab's web_url here, which git clones as well.
url: "https://gitlab.com/group/project",
Comment thread
coderabbitai[bot] marked this conversation as resolved.
sshUrl: "git@gitlab.com:group/project.git",
}),
).toBe("https://gitlab.com/group/project");
});

it("preserves existing clone transport behavior for other providers", () => {
expect(
getDefaultCloneUrl({
provider: "gitlab",
url: "https://gitlab.com/group/project.git",
sshUrl: "git@gitlab.com:group/project.git",
provider: "bitbucket",
url: "https://bitbucket.org/workspace/repo.git",
sshUrl: "git@bitbucket.org:workspace/repo.git",
}),
).toBe("git@gitlab.com:group/project.git");
).toBe("git@bitbucket.org:workspace/repo.git");
});

it("derives the clone folder name from any pasted clone URL", () => {
Expand Down
9 changes: 7 additions & 2 deletions packages/client-runtime/src/operations/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,16 @@ export function normalizePastedCloneUrl(input: string): string {
return `https://github.com/${repository}`;
}

/** GitHub and Forgejo default to HTTPS; other providers retain their existing SSH default. */
/**
* GitHub, GitLab, and Forgejo default to HTTPS: their CLIs install a Git credential helper on
* sign-in, while SSH needs a separately registered key. Other providers keep their SSH default.
*/
export function getDefaultCloneUrl(
repository: Pick<SourceControlRepositoryInfo, "provider" | "url" | "sshUrl">,
): string {
return repository.provider === "github" || repository.provider === "forgejo"
return repository.provider === "github" ||
repository.provider === "gitlab" ||
repository.provider === "forgejo"
? repository.url
: repository.sshUrl;
}
Expand Down
Loading