From ad28bd8db1a6e953dce999eea85becda1d90beae Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 6 Sep 2024 13:07:29 +0100 Subject: fix(remote): `fetch` and `list` status copy so that it the filesystem url is shown --- src/bin/git_remote_nostr/fetch.rs | 8 ++++++-- src/bin/git_remote_nostr/list.rs | 10 +++++----- src/lib/git/nostr_url.rs | 9 +++++++++ 3 files changed, 20 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/bin/git_remote_nostr/fetch.rs b/src/bin/git_remote_nostr/fetch.rs index 0a98db2..c48da85 100644 --- a/src/bin/git_remote_nostr/fetch.rs +++ b/src/bin/git_remote_nostr/fetch.rs @@ -121,7 +121,11 @@ fn fetch_from_git_server( let mut success = false; for protocol in &protocols_to_attempt { term.write_line( - format!("fetching from {} over {protocol}...", server_url.domain(),).as_str(), + format!( + "fetching over {protocol} from {}...", + server_url.short_name(), + ) + .as_str(), )?; let formatted_url = server_url.format_as(protocol, &decoded_nostr_url.user)?; @@ -152,7 +156,7 @@ fn fetch_from_git_server( } else { let error = anyhow!( "{} failed over {}{}", - server_url.domain(), + server_url.short_name(), join_with_and(&failed_protocols), if decoded_nostr_url.protocol.is_some() { " and nostr url contains protocol override so no other protocols were attempted" diff --git a/src/bin/git_remote_nostr/list.rs b/src/bin/git_remote_nostr/list.rs index ae76614..3614626 100644 --- a/src/bin/git_remote_nostr/list.rs +++ b/src/bin/git_remote_nostr/list.rs @@ -165,8 +165,8 @@ pub fn list_from_remote( for protocol in &protocols_to_attempt { term.write_line( format!( - "fetching ref list from {} over {protocol}...", - server_url.domain(), + "fetching ref list over {protocol} from {}...", + server_url.short_name(), ) .as_str(), )?; @@ -184,8 +184,8 @@ pub fn list_from_remote( if !failed_protocols.is_empty() { term.write_line( format!( - "list: succeeded over {protocol} for {}", - server_url.domain(), + "list: succeeded over {protocol} from {}", + server_url.short_name(), ) .as_str(), )?; @@ -210,7 +210,7 @@ pub fn list_from_remote( } else { let error = anyhow!( "{} failed over {}{}", - server_url.domain(), + server_url.short_name(), join_with_and(&failed_protocols), if decoded_nostr_url.protocol.is_some() { " and nostr url contains protocol override so no other protocols were attempted" diff --git a/src/lib/git/nostr_url.rs b/src/lib/git/nostr_url.rs index 2717916..d0e6d8a 100644 --- a/src/lib/git/nostr_url.rs +++ b/src/lib/git/nostr_url.rs @@ -324,6 +324,15 @@ impl CloneUrl { pub fn protocol(&self) -> ServerProtocol { self.protocol.clone() } + + pub fn short_name(&self) -> String { + let domain = self.domain(); + if domain.is_empty() { + self.original_string.to_string() + } else { + domain + } + } } fn replace_first_occurrence(s: &str, target: char, replacement: char) -> String { -- cgit v1.2.3