hosted-git-info is a Rust port of the original hosted-git-info project on npm.
It provides metadata and conversions from repository urls for GitHub, Bitbucket and GitLab.
It will let you identify and transform various git hosts URLs between protocols. It also can tell you what the URL is for the raw path for particular file for direct access without git.
Usage
First, URL parsing may fail for various reasons and therefore returns a Result:
use ;
assert!;
Let’s parse a valid URL and look at its components.
use ;
let url = "https://github.com/foo/bar.git#branch";
let info = from_url.unwrap;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
[HostedGitInfo] also implements the [str::FromStr] trait:
use ;
let url = "git+ssh://github.com:foo/bar.git";
let info: HostedGitInfo = url.parse.unwrap;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;