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/ngit/sub_commands/sync.rs') 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 From fa7adf840ac2d78defee398a61b60888f615622a Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 7 Aug 2025 17:49:02 +0100 Subject: fix(send): refs not confirmed are usually accepted having implemented 3b5c48f5a2a4b9be5d14baa8f5e801fefd5c1166, a ref pushed to refs/nostr/ on a github repo was accepted but was not confirmed --- src/bin/ngit/sub_commands/sync.rs | 4 ++-- src/lib/push.rs | 15 +++------------ 2 files changed, 5 insertions(+), 14 deletions(-) (limited to 'src/bin/ngit/sub_commands/sync.rs') diff --git a/src/bin/ngit/sub_commands/sync.rs b/src/bin/ngit/sub_commands/sync.rs index e7033b2..00dfe75 100644 --- a/src/bin/ngit/sub_commands/sync.rs +++ b/src/bin/ngit/sub_commands/sync.rs @@ -141,8 +141,8 @@ pub async fn launch(args: &SubCommandArgs) -> Result<()> { "error pushing updates to {remote_name}: error: {error}" ))?; } - Ok(failed_refs) => { - if failed_refs.is_empty() { + Ok(updated_refs) => { + if updated_refs.values().all(std::option::Option::is_none) { 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 diff --git a/src/lib/push.rs b/src/lib/push.rs index 0ee66cf..8cb0212 100644 --- a/src/lib/push.rs +++ b/src/lib/push.rs @@ -63,10 +63,9 @@ pub fn push_to_remote( } Ok(ref_updates_on_protocol) => { success = true; - if remote_refspecs.len() == ref_updates_on_protocol.len() - && ref_updates_on_protocol - .values() - .all(|error| error.is_none()) + if ref_updates_on_protocol + .values() + .all(|error| error.is_none()) { if !failed_protocols.is_empty() { term.write_line(format!("push: succeeded over {protocol}").as_str())?; @@ -444,14 +443,6 @@ pub async fn push_refs_and_generate_pr_or_pr_update_event( "push: error sending commit data to {normalized_url}: {error}" ))?; responses.push((clone_url.clone(), Err(anyhow!(error.clone())))); - } else if ref_updates.is_empty() { - term.write_line(&format!( - "push: error sending commit data to {normalized_url}: server didn't confirm acceptance" - ))?; - responses.push(( - clone_url.clone(), - Err(anyhow!("server didn't confirm acceptance")), - )); } else { responses.push((clone_url.clone(), Ok(()))); term.write_line(&format!("push: commit data sent to {normalized_url}"))?; -- cgit v1.2.3