From e882fde7d3fc7f2113196585b450f7065061abb9 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 12 Sep 2024 15:13:50 +0100 Subject: fix(remote): improve `push` status updates to bring them more into line to the native git client --- src/bin/git_remote_nostr/push.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 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 7f63eb0..5a19bb0 100644 --- a/src/bin/git_remote_nostr/push.rs +++ b/src/bin/git_remote_nostr/push.rs @@ -38,7 +38,8 @@ 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, report_on_sideband_progress, + report_on_transfer_progress, ProgressStatus, TransferDirection, }, }; @@ -355,7 +356,11 @@ fn push_to_remote( for protocol in &protocols_to_attempt { term.write_line( - format!("fetching {} ref list over {protocol}...", server_url.short_name(),).as_str(), + format!( + "fetching {} ref list over {protocol}...", + server_url.short_name(), + ) + .as_str(), )?; let formatted_url = server_url.format_as(protocol, &decoded_nostr_url.user)?; @@ -419,6 +424,20 @@ fn push_to_remote_url( } Ok(()) }); + remote_callbacks.transfer_progress(|stats| { + let _ = term.clear_last_lines(1); + report_on_transfer_progress( + &stats, + term, + TransferDirection::Push, + ProgressStatus::InProgress, + ); + true + }); + remote_callbacks.sideband_progress(|data| { + report_on_sideband_progress(data, term); + true + }); push_options.remote_callbacks(remote_callbacks); git_server_remote.push(remote_refspecs, Some(&mut push_options))?; let _ = git_server_remote.disconnect(); -- cgit v1.2.3