From a4bcaf98cc7a00a71f34ed382dc65414eaec5bff Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Tue, 17 Sep 2024 13:23:22 +0100 Subject: feat(remote): store successful protocol in config if another protocol was tried first and failed --- src/bin/git_remote_nostr/push.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/bin/git_remote_nostr/push.rs') diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs index daa7973..de18828 100644 --- a/src/bin/git_remote_nostr/push.rs +++ b/src/bin/git_remote_nostr/push.rs @@ -41,7 +41,7 @@ use crate::{ utils::{ 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, + push_error_is_not_authentication_failure, read_line, set_protocol_preference, Direction, }, }; @@ -351,7 +351,7 @@ fn push_to_remote( term: &Term, ) -> Result<()> { let server_url = git_server_url.parse::()?; - let protocols_to_attempt = get_write_protocols_to_try(&server_url, decoded_nostr_url); + let protocols_to_attempt = get_write_protocols_to_try(git_repo, &server_url, decoded_nostr_url); let mut failed_protocols = vec![]; let mut success = false; @@ -373,6 +373,7 @@ fn push_to_remote( success = true; if !failed_protocols.is_empty() { term.write_line(format!("fetch: succeeded over {protocol}").as_str())?; + let _ = set_protocol_preference(git_repo, protocol, &server_url, &Direction::Push); } } term.clear_last_lines(1)?; -- cgit v1.2.3