Skip to main content

parse_hosted_git

Function parse_hosted_git 

Source
pub fn parse_hosted_git(url: &str) -> Option<HostedGit>
Expand description

Parse a clone URL — in any form parse_git_spec accepts as input or produces as output — into its (host, owner, repo) components, when the host is one of the three providers npm / pnpm route through HTTPS tarballs. Returns None for any other host (including self-hosted GitLab / Gitea / Bitbucket Data Center): those still need a real git clone because no codeload-style HTTP archive is available.

Accepts:

  • https://github.com/owner/repo[.git]
  • git+https://github.com/owner/repo[.git]
  • git://github.com/owner/repo[.git]
  • ssh://git@github.com/owner/repo[.git]
  • git+ssh://git@github.com/owner/repo[.git] (npm canonical lockfile form)
  • git@github.com:owner/repo[.git] (scp shorthand, in case a caller parses raw lockfile fields without going through parse_git_spec)