Skip to content

Commit f45a364

Browse files
committed
fix(clients): default GitLab clones to HTTPS
Provider-selected GitLab clones used the SSH URL, so a host with glab signed in over HTTPS and no SSH key for GitLab failed with a host key error and had no way to pick the protocol. GitLab now joins GitHub and Forgejo on the HTTPS URL, which the glab credential helper authenticates.
1 parent e4eb997 commit f45a364

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

‎packages/client-runtime/src/operations/projects.test.ts‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,23 @@ describe("add project shared logic", () => {
8383
sshUrl: "ssh://[email protected]:2222/owner/repo.git",
8484
}),
8585
).toBe("https://forgejo.example.test:8443/owner/repo.git");
86-
});
87-
88-
it("preserves existing clone transport behavior for other providers", () => {
8986
expect(
9087
getDefaultCloneUrl({
9188
provider: "gitlab",
9289
url: "https://gitlab.com/group/project.git",
9390
sshUrl: "[email protected]:group/project.git",
9491
}),
95-
).toBe("[email protected]:group/project.git");
92+
).toBe("https://gitlab.com/group/project.git");
93+
});
94+
95+
it("preserves existing clone transport behavior for other providers", () => {
96+
expect(
97+
getDefaultCloneUrl({
98+
provider: "bitbucket",
99+
url: "https://bitbucket.org/workspace/repo.git",
100+
sshUrl: "[email protected]:workspace/repo.git",
101+
}),
102+
).toBe("[email protected]:workspace/repo.git");
96103
});
97104

98105
it("derives the clone folder name from any pasted clone URL", () => {

‎packages/client-runtime/src/operations/projects.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,16 @@ export function normalizePastedCloneUrl(input: string): string {
122122
return `https://github.com/${repository}`;
123123
}
124124

125-
/** GitHub and Forgejo default to HTTPS; other providers retain their existing SSH default. */
125+
/**
126+
* GitHub, GitLab, and Forgejo default to HTTPS: their CLIs install a Git credential helper on
127+
* sign-in, while SSH needs a separately registered key. Other providers keep their SSH default.
128+
*/
126129
export function getDefaultCloneUrl(
127130
repository: Pick<SourceControlRepositoryInfo, "provider" | "url" | "sshUrl">,
128131
): string {
129-
return repository.provider === "github" || repository.provider === "forgejo"
132+
return repository.provider === "github" ||
133+
repository.provider === "gitlab" ||
134+
repository.provider === "forgejo"
130135
? repository.url
131136
: repository.sshUrl;
132137
}

0 commit comments

Comments
 (0)