Skip to main content

parse_git_spec

Function parse_git_spec 

Source
pub fn parse_git_spec(
    spec: &str,
) -> Option<(String, Option<String>, Option<String>)>
Expand description

Parse a git dependency specifier into (clone_url, committish).

Recognized forms:

  • git+https://host/user/repo.git[#ref]
  • git+ssh://git@host/user/repo.git[#ref]
  • git://host/user/repo.git[#ref]
  • https://host/user/repo.git[#ref] (only when ending in .git)
  • user@host:path[.git][#ref] (scp-form, only for github.com / gitlab.com / bitbucket.org — matches pnpm 11 behavior, where unknown SCP hosts are treated as local paths) → ssh://user@host/path[.git]
  • github:user/repo[#ref]https://github.com/user/repo.git
  • gitlab:user/repo[#ref]https://gitlab.com/user/repo.git
  • bitbucket:user/repo[#ref]https://bitbucket.org/user/repo.git
  • user/repo[#ref] (bare GitHub shorthand, npm/pnpm compat) → https://github.com/user/repo.git

Returns None for any specifier that doesn’t look like a git URL, so the caller can fall through to other protocol parsers.