🥇 export from upstream (cd2f702)
This commit is contained in:
@@ -275,7 +275,7 @@ pub fn extract_git_remote_hosts(git_remote_output: &str) -> Vec<String> {
|
|||||||
hosts.insert(host.to_string());
|
hosts.insert(host.to_string());
|
||||||
}
|
}
|
||||||
} else if url.contains('@') && url.contains(':') {
|
} else if url.contains('@') && url.contains(':') {
|
||||||
// git@host:path format
|
// user@host:path format (e.g. git@github.com:user/repo.git)
|
||||||
let after_at = match url.find('@') {
|
let after_at = match url.find('@') {
|
||||||
Some(at) => &url[at + 1..],
|
Some(at) => &url[at + 1..],
|
||||||
None => continue,
|
None => continue,
|
||||||
@@ -288,6 +288,14 @@ pub fn extract_git_remote_hosts(git_remote_output: &str) -> Vec<String> {
|
|||||||
if !host.is_empty() {
|
if !host.is_empty() {
|
||||||
hosts.insert(host.to_string());
|
hosts.insert(host.to_string());
|
||||||
}
|
}
|
||||||
|
} else if url.contains(':') && !url.contains('/') || url.find(':') < url.find('/') {
|
||||||
|
// SCP-style without user: host:path (e.g. git.g4b.org:user/repo.git)
|
||||||
|
if let Some(colon) = url.find(':') {
|
||||||
|
let host = url[..colon].trim();
|
||||||
|
if !host.is_empty() && !host.contains(' ') {
|
||||||
|
hosts.insert(host.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1250,6 +1258,13 @@ https\thttps://gitlab.com/user/repo.git (push)
|
|||||||
assert!(hosts.is_empty());
|
assert!(hosts.is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn extract_hostnames_scp_without_user() {
|
||||||
|
let output = "origin\tgit.g4b.org:g4borg/sandcage.git (fetch)\norigin\tgit.g4b.org:g4borg/sandcage.git (push)\n";
|
||||||
|
let hosts = extract_git_remote_hosts(output);
|
||||||
|
assert_eq!(hosts, vec!["git.g4b.org"]);
|
||||||
|
}
|
||||||
|
|
||||||
// -- Task 7: build_ssh_discovery tests --
|
// -- Task 7: build_ssh_discovery tests --
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user