diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/bin/git_remote_nostr/utils.rs | 19 |
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 |
| 286 | pub fn fetch_or_list_error_is_not_authentication_failure(error: &anyhow::Error) -> bool { | 286 | pub 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 |
| 292 | pub fn push_error_is_not_authentication_failure(error: &anyhow::Error) -> bool { | 291 | pub fn push_error_is_not_authentication_failure(error: &anyhow::Error) -> bool { |
| 292 | !error_might_be_authentication_related(error) | ||
| 293 | } | ||
| 294 | |||
| 295 | pub 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)] |