pub fn normalize_git_remote(remote: &str) -> Option<Url>Expand description
Converts a Git remote into an absolute URL.
A remote that already carries a Git transport scheme is returned unchanged.
Git’s scp-like syntax becomes an ssh URL, and a filesystem path becomes a
file URL. Returns None for a relative path that does not resolve and for
anything else that cannot be expressed as a URL.
An scp-like path becomes an absolute URL path whether or not it began with a separator, because that is the form hosted forges expect. Git itself reads a separator-less scp path as relative to the login user’s home directory, so a self-hosted remote of that shape needs its URL written out by hand.
§Examples
assert_eq!(
normalize_git_remote("git@github.com:openwdl/wdl.git").map(|url| url.to_string()),
Some("ssh://git@github.com/openwdl/wdl.git".to_string())
);