Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ssh url -> local directory mapping #22

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ pub fn url_to_local_dir(url: &str) -> Result<UrlDir, Error> {

// trim port
let host = host.split(':').next().unwrap();
let host = host.split_once('@').map_or(host, |(_user, host)| host);

(format!("{host}-{ident}"), url.to_owned())
};
Expand Down Expand Up @@ -305,6 +306,17 @@ mod test {

assert_eq!("https://gitlab.com/gilrs-project/gilrs", canonical);
assert_eq!("gilrs-7804d1d6a17891c9", dir_name);

let super::UrlDir {
dir_name,
canonical,
} = url_to_local_dir("ssh://git@github.com/rust-lang/crates.io-index.git").unwrap();

assert_eq!(
"ssh://git@github.com/rust-lang/crates.io-index.git",
canonical
);
assert_eq!("github.com-01dba724c7458575", dir_name);
}

#[test]
Expand Down