From 38969bbfadf2854f6acb1e515f8f388a01a018c2 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 9 May 2025 20:00:24 +0100 Subject: fix: always try git servers over other protocols remove the code that guessed whether it was an authentication failure and gave up is it wasn't. this prevents it from trying http for push when ssh is not supported eg. ngit-relay --- src/bin/git_remote_nostr/fetch.rs | 9 +-------- src/bin/git_remote_nostr/list.rs | 11 ++--------- src/bin/git_remote_nostr/push.rs | 6 +----- src/bin/git_remote_nostr/utils.rs | 10 ---------- 4 files changed, 4 insertions(+), 32 deletions(-) (limited to 'src') 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; use nostr_sdk::{Event, ToBech32}; use crate::utils::{ - Direction, fetch_or_list_error_is_not_authentication_failure, - find_proposal_and_patches_by_branch_name, get_oids_from_fetch_batch, + Direction, find_proposal_and_patches_by_branch_name, get_oids_from_fetch_batch, get_open_or_draft_proposals, get_read_protocols_to_try, join_with_and, set_protocol_preference, }; @@ -196,12 +195,6 @@ pub fn fetch_from_git_server( format!("fetch: {formatted_url} failed over {protocol}: {error}").as_str(), )?; failed_protocols.push(protocol); - if protocol == &ServerProtocol::Ssh - && fetch_or_list_error_is_not_authentication_failure(&error) - { - // authenticated by failed to complete request - break; - } } else { success = true; 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::{ fetch::{fetch_from_git_server, make_commits_for_proposal}, git::Repo, utils::{ - Direction, fetch_or_list_error_is_not_authentication_failure, get_open_or_draft_proposals, - get_read_protocols_to_try, get_short_git_server_name, join_with_and, - set_protocol_preference, + Direction, get_open_or_draft_proposals, get_read_protocols_to_try, + get_short_git_server_name, join_with_and, set_protocol_preference, }, }; @@ -244,12 +243,6 @@ pub fn list_from_remote( format!("list: {formatted_url} failed over {protocol}: {error}").as_str(), )?; failed_protocols.push(protocol); - if protocol == &ServerProtocol::Ssh - && fetch_or_list_error_is_not_authentication_failure(&error) - { - // authenticated by failed to complete request - break; - } } } } 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::{ utils::{ Direction, find_proposal_and_patches_by_branch_name, get_all_proposals, get_remote_name_by_url, get_short_git_server_name, get_write_protocols_to_try, - join_with_and, push_error_is_not_authentication_failure, read_line, - set_protocol_preference, + join_with_and, read_line, set_protocol_preference, }, }; @@ -430,9 +429,6 @@ fn push_to_remote( format!("push: {formatted_url} failed over {protocol}: {error}").as_str(), )?; failed_protocols.push(protocol); - if push_error_is_not_authentication_failure(&error) { - break; - } } else { success = true; 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( ) } -/// to understand whether to try over another protocol -pub fn fetch_or_list_error_is_not_authentication_failure(error: &anyhow::Error) -> bool { - !error_might_be_authentication_related(error) -} - -/// to understand whether to try over another protocol -pub fn push_error_is_not_authentication_failure(error: &anyhow::Error) -> bool { - !error_might_be_authentication_related(error) -} - pub fn error_might_be_authentication_related(error: &anyhow::Error) -> bool { let error_str = error.to_string(); for s in [ -- cgit v1.2.3