From 0b9ebd63be13ee403c415d4a29538b94f9e7cffe Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 6 Sep 2024 11:29:27 +0100 Subject: feat(remote): just use ssh if auth succeeds and don't proceed to https or http --- src/bin/git_remote_nostr/utils.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/bin/git_remote_nostr/utils.rs') diff --git a/src/bin/git_remote_nostr/utils.rs b/src/bin/git_remote_nostr/utils.rs index a31dcbf..90ea848 100644 --- a/src/bin/git_remote_nostr/utils.rs +++ b/src/bin/git_remote_nostr/utils.rs @@ -282,6 +282,7 @@ pub fn get_read_protocols_to_try( vec![ ServerProtocol::UnauthHttp, ServerProtocol::Ssh, + // note: list and fetch stop here if ssh was authenticated ServerProtocol::Http, ] } else if server_url.protocol() == ServerProtocol::Ftp { @@ -290,11 +291,17 @@ pub fn get_read_protocols_to_try( vec![ ServerProtocol::UnauthHttps, ServerProtocol::Ssh, + // note: list and fetch stop here if ssh was authenticated ServerProtocol::Https, ] } } +pub fn error_is_not_authentication_failure(error: &anyhow::Error) -> bool { + let error_str = error.to_string(); + error_str.contains("Permission to") || error_str.contains("Repository not found") +} + #[cfg(test)] mod tests { use super::*; -- cgit v1.2.3