diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/bin/git_remote_nostr/fetch.rs | 9 | ||||
| -rw-r--r-- | src/bin/git_remote_nostr/list.rs | 11 | ||||
| -rw-r--r-- | src/bin/git_remote_nostr/push.rs | 6 | ||||
| -rw-r--r-- | src/bin/git_remote_nostr/utils.rs | 10 |
4 files changed, 4 insertions, 32 deletions
diff --git a/src/bin/git_remote_nostr/fetch.rs b/src/bin/git_remote_nostr/fetch.rs index a7210d0..34a02fc 100644 --- a/src/bin/git_remote_nostr/fetch.rs +++ b/src/bin/git_remote_nostr/fetch.rs | |||
| @@ -24,8 +24,7 @@ use nostr::nips::nip19; | |||
| 24 | use nostr_sdk::{Event, ToBech32}; | 24 | use nostr_sdk::{Event, ToBech32}; |
| 25 | 25 | ||
| 26 | use crate::utils::{ | 26 | use crate::utils::{ |
| 27 | Direction, fetch_or_list_error_is_not_authentication_failure, | 27 | Direction, find_proposal_and_patches_by_branch_name, get_oids_from_fetch_batch, |
| 28 | find_proposal_and_patches_by_branch_name, get_oids_from_fetch_batch, | ||
| 29 | get_open_or_draft_proposals, get_read_protocols_to_try, join_with_and, set_protocol_preference, | 28 | get_open_or_draft_proposals, get_read_protocols_to_try, join_with_and, set_protocol_preference, |
| 30 | }; | 29 | }; |
| 31 | 30 | ||
| @@ -196,12 +195,6 @@ pub fn fetch_from_git_server( | |||
| 196 | format!("fetch: {formatted_url} failed over {protocol}: {error}").as_str(), | 195 | format!("fetch: {formatted_url} failed over {protocol}: {error}").as_str(), |
| 197 | )?; | 196 | )?; |
| 198 | failed_protocols.push(protocol); | 197 | failed_protocols.push(protocol); |
| 199 | if protocol == &ServerProtocol::Ssh | ||
| 200 | && fetch_or_list_error_is_not_authentication_failure(&error) | ||
| 201 | { | ||
| 202 | // authenticated by failed to complete request | ||
| 203 | break; | ||
| 204 | } | ||
| 205 | } else { | 198 | } else { |
| 206 | success = true; | 199 | success = true; |
| 207 | if !failed_protocols.is_empty() { | 200 | if !failed_protocols.is_empty() { |
diff --git a/src/bin/git_remote_nostr/list.rs b/src/bin/git_remote_nostr/list.rs index eba573b..2d233ae 100644 --- a/src/bin/git_remote_nostr/list.rs +++ b/src/bin/git_remote_nostr/list.rs | |||
| @@ -22,9 +22,8 @@ use crate::{ | |||
| 22 | fetch::{fetch_from_git_server, make_commits_for_proposal}, | 22 | fetch::{fetch_from_git_server, make_commits_for_proposal}, |
| 23 | git::Repo, | 23 | git::Repo, |
| 24 | utils::{ | 24 | utils::{ |
| 25 | Direction, fetch_or_list_error_is_not_authentication_failure, get_open_or_draft_proposals, | 25 | Direction, get_open_or_draft_proposals, get_read_protocols_to_try, |
| 26 | get_read_protocols_to_try, get_short_git_server_name, join_with_and, | 26 | get_short_git_server_name, join_with_and, set_protocol_preference, |
| 27 | set_protocol_preference, | ||
| 28 | }, | 27 | }, |
| 29 | }; | 28 | }; |
| 30 | 29 | ||
| @@ -244,12 +243,6 @@ pub fn list_from_remote( | |||
| 244 | format!("list: {formatted_url} failed over {protocol}: {error}").as_str(), | 243 | format!("list: {formatted_url} failed over {protocol}: {error}").as_str(), |
| 245 | )?; | 244 | )?; |
| 246 | failed_protocols.push(protocol); | 245 | failed_protocols.push(protocol); |
| 247 | if protocol == &ServerProtocol::Ssh | ||
| 248 | && fetch_or_list_error_is_not_authentication_failure(&error) | ||
| 249 | { | ||
| 250 | // authenticated by failed to complete request | ||
| 251 | break; | ||
| 252 | } | ||
| 253 | } | 246 | } |
| 254 | } | 247 | } |
| 255 | } | 248 | } |
diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs index 0cb1107..4eae92f 100644 --- a/src/bin/git_remote_nostr/push.rs +++ b/src/bin/git_remote_nostr/push.rs | |||
| @@ -45,8 +45,7 @@ use crate::{ | |||
| 45 | utils::{ | 45 | utils::{ |
| 46 | Direction, find_proposal_and_patches_by_branch_name, get_all_proposals, | 46 | Direction, find_proposal_and_patches_by_branch_name, get_all_proposals, |
| 47 | get_remote_name_by_url, get_short_git_server_name, get_write_protocols_to_try, | 47 | get_remote_name_by_url, get_short_git_server_name, get_write_protocols_to_try, |
| 48 | join_with_and, push_error_is_not_authentication_failure, read_line, | 48 | join_with_and, read_line, set_protocol_preference, |
| 49 | set_protocol_preference, | ||
| 50 | }, | 49 | }, |
| 51 | }; | 50 | }; |
| 52 | 51 | ||
| @@ -430,9 +429,6 @@ fn push_to_remote( | |||
| 430 | format!("push: {formatted_url} failed over {protocol}: {error}").as_str(), | 429 | format!("push: {formatted_url} failed over {protocol}: {error}").as_str(), |
| 431 | )?; | 430 | )?; |
| 432 | failed_protocols.push(protocol); | 431 | failed_protocols.push(protocol); |
| 433 | if push_error_is_not_authentication_failure(&error) { | ||
| 434 | break; | ||
| 435 | } | ||
| 436 | } else { | 432 | } else { |
| 437 | success = true; | 433 | success = true; |
| 438 | if !failed_protocols.is_empty() { | 434 | if !failed_protocols.is_empty() { |
diff --git a/src/bin/git_remote_nostr/utils.rs b/src/bin/git_remote_nostr/utils.rs index 5048ce2..3a9f07d 100644 --- a/src/bin/git_remote_nostr/utils.rs +++ b/src/bin/git_remote_nostr/utils.rs | |||
| @@ -354,16 +354,6 @@ pub fn set_protocol_preference( | |||
| 354 | ) | 354 | ) |
| 355 | } | 355 | } |
| 356 | 356 | ||
| 357 | /// to understand whether to try over another protocol | ||
| 358 | pub fn fetch_or_list_error_is_not_authentication_failure(error: &anyhow::Error) -> bool { | ||
| 359 | !error_might_be_authentication_related(error) | ||
| 360 | } | ||
| 361 | |||
| 362 | /// to understand whether to try over another protocol | ||
| 363 | pub fn push_error_is_not_authentication_failure(error: &anyhow::Error) -> bool { | ||
| 364 | !error_might_be_authentication_related(error) | ||
| 365 | } | ||
| 366 | |||
| 367 | pub fn error_might_be_authentication_related(error: &anyhow::Error) -> bool { | 357 | pub fn error_might_be_authentication_related(error: &anyhow::Error) -> bool { |
| 368 | let error_str = error.to_string(); | 358 | let error_str = error.to_string(); |
| 369 | for s in [ | 359 | for s in [ |