git-url-parse

Crates.io docs.rs licence Github actions build status

Supports common protocols as specified by the Pro Git book

See: 4.1 Git on the Server - The Protocols

Supports parsing SSH/HTTPS repo urls for: * Github * Bitbucket * Azure Devops

See tests/parse.rs for expected output for a variety of inputs.


URLs that use the ssh:// protocol (implicitly or explicitly) undergo a small normalization process in order to be parsed.

Internally uses Url::parse() from the Url crate after normalization.

Examples

Run example with debug output

shell $ RUST_LOG=git_url_parse cargo run --example multi

Simple usage and output

```rust use giturlparse::GitUrl;

fn main() { println!("SSH: {:?}", GitUrl::parse("git@github.com:tjtelan/git-url-parse-rs.git")); println!("HTTPS: {:?}", GitUrl::parse("https://github.com/tjtelan/git-url-parse-rs")); } ```

Example Output

bash SSH: Ok(GitUrl { href: "git@github.com:tjtelan/git-url-parse-rs.git", host: Some("github.com"), name: "git-url-parse-rs", owner: Some("tjtelan"), organization: None, fullname: "tjtelan/git-url-parse-rs", protocol: Ssh, user: Some("git"), token: None, port: None, path: "tjtelan/git-url-parse-rs.git", git_suffix: true }) HTTPS: Ok(GitUrl { href: "https://github.com/tjtelan/git-url-parse-rs", host: Some("github.com"), name: "git-url-parse-rs", owner: Some("tjtelan"), organization: None, fullname: "tjtelan/git-url-parse-rs", protocol: Https, user: None, token: None, port: None, path: "/tjtelan/git-url-parse-rs", git_suffix: false })