From 646d05e44946c5a248cb8c5b7d852ed316b9592e Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 7 Aug 2025 10:21:28 +0100 Subject: fix(send): push PR refs to non-grasp servers attempt to use a range of protocols instead of unath http --- src/bin/ngit/sub_commands/sync.rs | 66 ++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 26 deletions(-) (limited to 'src/bin') diff --git a/src/bin/ngit/sub_commands/sync.rs b/src/bin/ngit/sub_commands/sync.rs index c1a3484..e7033b2 100644 --- a/src/bin/ngit/sub_commands/sync.rs +++ b/src/bin/ngit/sub_commands/sync.rs @@ -127,33 +127,47 @@ pub async fn launch(args: &SubCommandArgs) -> Result<()> { term.write_line(&format!("{remote_name} already in sync"))?; } // report already in sync - } else if let Err(error) = push_to_remote( - &git_repo, - url, - &decoded_nostr_url, - &refspecs, - &term, - *is_grasp_server, - ) { - term.write_line(&format!( - "error pushing updates to {remote_name}: error: {error}" - ))?; - } else if *is_grasp_server || args.force { - term.write_line(&format!("{remote_name} sync completed"))?; - // TODO we only know if there was an error but not if it - // rejected any updates } else { - // we should report on refs not force pushed - term.write_line(&format!("{remote_name} sync completed"))?; - } - for name in ¬_deleted { - term.write_line(&format!(" - {name} not deleted"))?; - } - for name in ¬_updated { - term.write_line(&format!(" - {name} not updated due to conflicts"))?; - } - if !not_updated.is_empty() || !not_deleted.is_empty() { - term.write_line("run `ngit sync --force` to delete refs or overwrite conflicts and potentially lose work")?; + match push_to_remote( + &git_repo, + url, + &decoded_nostr_url, + &refspecs, + &term, + *is_grasp_server, + ) { + Err(error) => { + term.write_line(&format!( + "error pushing updates to {remote_name}: error: {error}" + ))?; + } + Ok(failed_refs) => { + if failed_refs.is_empty() { + if *is_grasp_server || args.force { + term.write_line(&format!("{remote_name} sync completed"))?; + // TODO we only know if there was an error but not + // if it rejected any + // updates + } else { + // we should report on refs not force pushed + term.write_line(&format!("{remote_name} sync completed"))?; + } + } else { + term.write_line(&format!( + "{remote_name} sync completed but not all changes were accepted" + ))?; + } + for name in ¬_deleted { + term.write_line(&format!(" - {name} not deleted"))?; + } + for name in ¬_updated { + term.write_line(&format!(" - {name} not updated due to conflicts"))?; + } + if !not_updated.is_empty() || !not_deleted.is_empty() { + term.write_line("run `ngit sync --force` to delete refs or overwrite conflicts and potentially lose work")?; + } + } + } } } -- cgit v1.2.3