upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/git_remote_nostr/fetch.rs8
-rw-r--r--src/bin/git_remote_nostr/list.rs10
-rw-r--r--src/lib/git/nostr_url.rs9
3 files changed, 20 insertions, 7 deletions
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(
121 let mut success = false; 121 let mut success = false;
122 for protocol in &protocols_to_attempt { 122 for protocol in &protocols_to_attempt {
123 term.write_line( 123 term.write_line(
124 format!("fetching from {} over {protocol}...", server_url.domain(),).as_str(), 124 format!(
125 "fetching over {protocol} from {}...",
126 server_url.short_name(),
127 )
128 .as_str(),
125 )?; 129 )?;
126 130
127 let formatted_url = server_url.format_as(protocol, &decoded_nostr_url.user)?; 131 let formatted_url = server_url.format_as(protocol, &decoded_nostr_url.user)?;
@@ -152,7 +156,7 @@ fn fetch_from_git_server(
152 } else { 156 } else {
153 let error = anyhow!( 157 let error = anyhow!(
154 "{} failed over {}{}", 158 "{} failed over {}{}",
155 server_url.domain(), 159 server_url.short_name(),
156 join_with_and(&failed_protocols), 160 join_with_and(&failed_protocols),
157 if decoded_nostr_url.protocol.is_some() { 161 if decoded_nostr_url.protocol.is_some() {
158 " and nostr url contains protocol override so no other protocols were attempted" 162 " 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(
165 for protocol in &protocols_to_attempt { 165 for protocol in &protocols_to_attempt {
166 term.write_line( 166 term.write_line(
167 format!( 167 format!(
168 "fetching ref list from {} over {protocol}...", 168 "fetching ref list over {protocol} from {}...",
169 server_url.domain(), 169 server_url.short_name(),
170 ) 170 )
171 .as_str(), 171 .as_str(),
172 )?; 172 )?;
@@ -184,8 +184,8 @@ pub fn list_from_remote(
184 if !failed_protocols.is_empty() { 184 if !failed_protocols.is_empty() {
185 term.write_line( 185 term.write_line(
186 format!( 186 format!(
187 "list: succeeded over {protocol} for {}", 187 "list: succeeded over {protocol} from {}",
188 server_url.domain(), 188 server_url.short_name(),
189 ) 189 )
190 .as_str(), 190 .as_str(),
191 )?; 191 )?;
@@ -210,7 +210,7 @@ pub fn list_from_remote(
210 } else { 210 } else {
211 let error = anyhow!( 211 let error = anyhow!(
212 "{} failed over {}{}", 212 "{} failed over {}{}",
213 server_url.domain(), 213 server_url.short_name(),
214 join_with_and(&failed_protocols), 214 join_with_and(&failed_protocols),
215 if decoded_nostr_url.protocol.is_some() { 215 if decoded_nostr_url.protocol.is_some() {
216 " and nostr url contains protocol override so no other protocols were attempted" 216 " 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 {
324 pub fn protocol(&self) -> ServerProtocol { 324 pub fn protocol(&self) -> ServerProtocol {
325 self.protocol.clone() 325 self.protocol.clone()
326 } 326 }
327
328 pub fn short_name(&self) -> String {
329 let domain = self.domain();
330 if domain.is_empty() {
331 self.original_string.to_string()
332 } else {
333 domain
334 }
335 }
327} 336}
328 337
329fn replace_first_occurrence(s: &str, target: char, replacement: char) -> String { 338fn replace_first_occurrence(s: &str, target: char, replacement: char) -> String {