From 52370f542dad87ab029a5d701cc46658d5aef91b Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Tue, 11 Nov 2025 07:21:08 +0000 Subject: fix: cli output line deletion during fetch also reduce the clutter in the cli output for grasp servers. --- src/bin/git_remote_nostr/list.rs | 1 - src/bin/git_remote_nostr/push.rs | 1 - src/bin/ngit/sub_commands/sync.rs | 9 ++------- src/lib/list.rs | 38 +++++++++++++++++++------------------- 4 files changed, 21 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/bin/git_remote_nostr/list.rs b/src/bin/git_remote_nostr/list.rs index b3ef2f6..803cc8f 100644 --- a/src/bin/git_remote_nostr/list.rs +++ b/src/bin/git_remote_nostr/list.rs @@ -31,7 +31,6 @@ pub async fn run_list( git_repo, &repo_ref.git_server, &repo_ref.to_nostr_git_url(&None), - &repo_ref.grasp_servers(), ); let mut state = if let Some(nostr_state) = nostr_state { diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs index e880f0d..c35699d 100644 --- a/src/bin/git_remote_nostr/push.rs +++ b/src/bin/git_remote_nostr/push.rs @@ -75,7 +75,6 @@ pub async fn run_push( git_repo, &repo_ref.git_server, &repo_ref.to_nostr_git_url(&None), - &repo_ref.grasp_servers(), ) }); diff --git a/src/bin/ngit/sub_commands/sync.rs b/src/bin/ngit/sub_commands/sync.rs index b7eb812..2722da2 100644 --- a/src/bin/ngit/sub_commands/sync.rs +++ b/src/bin/ngit/sub_commands/sync.rs @@ -77,13 +77,8 @@ pub async fn launch(args: &SubCommandArgs) -> Result<()> { let term = console::Term::stderr(); - let remote_states = list_from_remotes( - &term, - &git_repo, - &repo_ref.git_server, - &decoded_nostr_url, - &repo_ref.grasp_servers(), - ); + let remote_states = + list_from_remotes(&term, &git_repo, &repo_ref.git_server, &decoded_nostr_url); let missing_refs = fetch_missing_refs(&git_repo, &nostr_state, &remote_states, &decoded_nostr_url); diff --git a/src/lib/list.rs b/src/lib/list.rs index 639140e..733936a 100644 --- a/src/lib/list.rs +++ b/src/lib/list.rs @@ -9,7 +9,7 @@ use crate::{ Repo, RepoActions, nostr_url::{CloneUrl, NostrUrlDecoded, ServerProtocol}, }, - repo_ref::is_grasp_server_in_list, + repo_ref::is_grasp_server_clone_url, utils::{Direction, get_read_protocols_to_try, join_with_and, set_protocol_preference}, }; @@ -18,12 +18,11 @@ pub fn list_from_remotes( git_repo: &Repo, git_servers: &Vec, decoded_nostr_url: &NostrUrlDecoded, - grasp_servers: &[String], ) -> HashMap, bool)> { let mut remote_states = HashMap::new(); let mut errors = HashMap::new(); for url in git_servers { - let is_grasp_server = is_grasp_server_in_list(url, grasp_servers); + let is_grasp_server = is_grasp_server_clone_url(url); match list_from_remote(term, git_repo, url, decoded_nostr_url, is_grasp_server) { Err(error) => { errors.insert(url, error); @@ -72,8 +71,7 @@ pub fn list_from_remote( match res { Ok(state) => { remote_state = Some(state); - term.clear_last_lines(1)?; - if !failed_protocols.is_empty() { + if !is_grasp_server && !failed_protocols.is_empty() { term.write_line( format!( "list: succeeded over {protocol} from {}", @@ -87,27 +85,27 @@ pub fn list_from_remote( break; } Err(error) => { - term.clear_last_lines(1)?; - term.write_line(&format!( - "list: {formatted_url} failed over {protocol}{}: {error}", - if protocol == &ServerProtocol::Ssh { - if let Some(ssh_key_file) = &decoded_nostr_url.ssh_key_file_path() { - format!(" with ssh key from {ssh_key_file}") + if is_grasp_server { + term.write_line(&format!("list: failed: {error}"))?; + } else { + term.write_line(&format!( + "list: {formatted_url} failed over {protocol}{}: {error}", + if protocol == &ServerProtocol::Ssh { + if let Some(ssh_key_file) = &decoded_nostr_url.ssh_key_file_path() { + format!(" with ssh key from {ssh_key_file}") + } else { + String::new() + } } else { String::new() } - } else { - String::new() - } - ))?; + ))?; + } failed_protocols.push(protocol); } } } if let Some(remote_state) = remote_state { - if failed_protocols.is_empty() { - term.clear_last_lines(1)?; - } Ok(remote_state) } else { let error = anyhow!( @@ -120,7 +118,9 @@ pub fn list_from_remote( "" }, ); - term.write_line(format!("list: {error}").as_str())?; + if !is_grasp_server { + term.write_line(format!("list: {error}").as_str())?; + } Err(error) } } -- cgit v1.2.3