Skip to main content

Crate parse_git_url

Crate parse_git_url 

Source
Expand description

Parse Git repository URLs into a stable, documented Rust data structure.

GitUrl::parse supports the host-specific layouts currently covered by the test suite and README: GitHub, Bitbucket, and Azure DevOps over SSH, HTTP(S), and related URL schemes. Local Unix paths and relative Windows paths are also supported.

Absolute Windows drive paths such as C:\repo.git and file:///C:/repo.git are intentionally unsupported.

§Examples

use parse_git_url::{GitUrl, Scheme};

let parsed = GitUrl::parse("git@github.com:tjtelan/git-url-parse-rs.git")
    .expect("example URL should parse");

assert_eq!(parsed.host.as_deref(), Some("github.com"));
assert_eq!(parsed.owner.as_deref(), Some("tjtelan"));
assert_eq!(parsed.name, "git-url-parse-rs");
assert_eq!(parsed.scheme, Scheme::Ssh);

Structs§

FromStrError
GitUrl
GitUrl represents an input URL used by git hosting tools and repositories.
NormalizeUrlError

Enums§

FromStrErrorKind
NormalizeUrlErrorKind
Scheme
Supported URI schemes for parsing

Functions§

normalize_url
normalize_url takes in url as &str and takes an opinionated approach to identify ssh:// or file:// urls that require more information to be added so that they can be parsed more effectively by url::Url::parse()