upleb.uk

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

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-09-11 16:22:09 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2024-09-12 07:21:18 +0100
commit708f4137a89a3ce18db7bc416dd60bf27f8302aa (patch)
treefb19027c86cafedc328562a5762b886cd566f1cf
parentc7faf80ab9d2639211d3978f1527286b3ce86ce0 (diff)
fix(remote): identify auth failure
so that attempts can be made to use a fallback protocol
-rw-r--r--src/bin/git_remote_nostr/utils.rs19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/bin/git_remote_nostr/utils.rs b/src/bin/git_remote_nostr/utils.rs
index 3039fe3..9be2580 100644
--- a/src/bin/git_remote_nostr/utils.rs
+++ b/src/bin/git_remote_nostr/utils.rs
@@ -284,14 +284,27 @@ pub fn get_write_protocols_to_try(
284 284
285/// to understand whether to try over another protocol 285/// to understand whether to try over another protocol
286pub fn fetch_or_list_error_is_not_authentication_failure(error: &anyhow::Error) -> bool { 286pub fn fetch_or_list_error_is_not_authentication_failure(error: &anyhow::Error) -> bool {
287 let error_str = error.to_string(); 287 !error_might_be_authentication_related(error)
288 error_str.contains("Permission to") || error_str.contains("Repository not found")
289} 288}
290 289
291/// to understand whether to try over another protocol 290/// to understand whether to try over another protocol
292pub fn push_error_is_not_authentication_failure(error: &anyhow::Error) -> bool { 291pub fn push_error_is_not_authentication_failure(error: &anyhow::Error) -> bool {
292 !error_might_be_authentication_related(error)
293}
294
295pub fn error_might_be_authentication_related(error: &anyhow::Error) -> bool {
293 let error_str = error.to_string(); 296 let error_str = error.to_string();
294 error_str.contains("Permission to") || error_str.contains("Repository not found") 297 for s in [
298 "no ssh keys found",
299 "invalid or unknown remote ssh",
300 "Permission to",
301 "Repository not found",
302 ] {
303 if error_str.contains(s) {
304 return true;
305 }
306 }
307 false
295} 308}
296 309
297#[cfg(test)] 310#[cfg(test)]