git-clone-canonical 0.1.5

Clone git repositories into a local path derived from the URL.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::Url;
use test_case::test_case;

#[test_case("https://github.com/nathan-at-least/git-clone-canonical", "github.com", &["nathan-at-least", "git-clone-canonical"])]
#[test_case("https://github.com/nathan-at-least/git-clone-canonical.git", "github.com", &["nathan-at-least", "git-clone-canonical.git"])]
#[test_case("git@github.com:nathan-at-least/git-clone-canonical.git", "github.com", &["nathan-at-least", "git-clone-canonical.git"])]
fn parse_to_path_segments(
    input: &str,
    expected_domain: &str,
    expected_path_segments: &[&str],
) -> Result<(), <Url as std::str::FromStr>::Err> {
    let url: Url = input.parse()?;
    assert_eq!(url.domain(), expected_domain);
    let segments: Vec<&str> = url.path_segments().collect();
    assert_eq!(segments.as_slice(), expected_path_segments);
    Ok(())
}