fix(github): recognise remotes cloned through ssh.github.com (#3391)

A clone over GitHub's SSH-over-HTTPS host (ssh://git@ssh.github.com:443/o/r.git or git@ssh.github.com:o/r.git) wasn't recognised as a GitHub repository. parseGitHubRemote now accepts ssh.github.com for SSH remotes; https://ssh.github.com stays rejected. Sibling of #3379.
This commit is contained in:
l0ng-ai
2026-11-14 22:57:59 +08:00
committed by GitHub
parent 13e18af777
commit 41b581eafd
2 changed files with 5 additions and 2 deletions
+3
View File
@@ -401,6 +401,9 @@ describe("pull request helpers", () => {
"ssh://git@github.com/o/r.git",
"ssh://git@github.com:22/o/r.git",
"git://github.com/o/r",
// GitHub's SSH-over-HTTPS host.
"ssh://git@ssh.github.com:443/o/r.git",
"git@ssh.github.com:o/r.git",
])
expect(parseGitHubRemote(url), url).toEqual({ owner: "o", name: "r" });
expect(parseGitHubRemote("https://gitlab.com/o/r.git")).toBeNull();
+2 -2
View File
@@ -413,10 +413,10 @@ export function repositoryDisplayName(
return showOwner ? `${repo.owner}/${repo.name}` : repo.name;
}
/** `owner/name` of a github.com remote URL (https, ssh or scp-like), else null. */
/** `owner/name` of a github.com remote URL (https, ssh or scp-like; SSH also via ssh.github.com), else null. */
export function parseGitHubRemote(url: string): GHRepositoryCoordinates | null {
const m =
/^(?:https?:\/\/(?:[^@/]+@)?|ssh:\/\/(?:[^@/]+@)?|git:\/\/|(?:[^@/]+@)?)(?:www\.)?github\.com(?::\d+(?=\/))?[:/]+([^/]+)\/([^/]+?)(?:\.git)?\/?$/i.exec(
/^(?:(?:https?:\/\/(?:[^@/]+@)?|git:\/\/)(?:www\.)?|(?:ssh:\/\/(?:[^@/]+@)?|(?:[^@/]+@)?)(?:www\.|ssh\.)?)github\.com(?::\d+(?=\/))?[:/]+([^/]+)\/([^/]+?)(?:\.git)?\/?$/i.exec(
url.trim(),
);
return m ? { owner: m[1]!, name: m[2]! } : null;