#git #github #bitbucket #gitlab

hosted-git-info

Provides metadata and conversions from repository urls for GitHub, Bitbucket and GitLab

3 releases

0.1.2 Sep 15, 2021
0.1.1 Aug 9, 2021
0.1.0 Aug 9, 2021

#7 in #bitbucket

ISC license

33KB
514 lines

hosted-git-info

Provides metadata and conversions from repository urls for GitHub, Bitbucket and GitLab.

This is a Rust port of the original hosted-git-info project on npm.

This 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

use hosted_git_info::HostedGitInfo;

fn main() {
    let url = "https://github.com/foo/bar.git#branch";
    let info = HostedGitInfo::from_url(url).unwrap();
    assert_eq!(info.provider, Provider::GitHub);
    assert_eq!(info.user, Some("foo"));
    assert_eq!(info.project, "bar");
    assert_eq!(info.committish, Some("branch"));
}

License

This project is licensed under the ISC license (LICENSE or http://opensource.org/licenses/ISC).

Dependencies

~1.7–2.6MB
~81K SLoC