From 40b439ae4d69b858274be51dd5af513c3b4f46f0 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 13 Feb 2026 10:51:25 +0000 Subject: feat: add spinner for git fetch in non-verbose mode Shows a progress spinner when fetching from git remotes in non-verbose mode. Suppresses git fetch output and listing messages when not in verbose mode. Uses NGITTEST environment variable for test timeouts. --- src/bin/git_remote_nostr/list.rs | 6 ++++-- src/bin/git_remote_nostr/main.rs | 13 +++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'src/bin/git_remote_nostr') diff --git a/src/bin/git_remote_nostr/list.rs b/src/bin/git_remote_nostr/list.rs index 7753ba1..4a7c1ec 100644 --- a/src/bin/git_remote_nostr/list.rs +++ b/src/bin/git_remote_nostr/list.rs @@ -4,7 +4,7 @@ use anyhow::{Context, Result}; use client::get_state_from_cache; use git::RepoActions; use ngit::{ - client, + client::{self, is_verbose}, fetch::fetch_from_git_server, git::{self}, git_events::{KIND_PULL_REQUEST, KIND_PULL_REQUEST_UPDATE, event_to_cover_letter, tag_value}, @@ -27,7 +27,9 @@ pub async fn run_list( let term = console::Term::stderr(); - term.write_line("git servers: listing refs...")?; + if is_verbose() { + term.write_line("git servers: listing refs...")?; + } let remote_states = list_from_remotes( &term, git_repo, diff --git a/src/bin/git_remote_nostr/main.rs b/src/bin/git_remote_nostr/main.rs index b26981d..3663d5b 100644 --- a/src/bin/git_remote_nostr/main.rs +++ b/src/bin/git_remote_nostr/main.rs @@ -12,7 +12,7 @@ use std::{ }; use anyhow::{Context, Result, bail}; -use client::{Connect, consolidate_fetch_reports, get_repo_ref_from_cache}; +use client::{Connect, consolidate_fetch_reports, get_repo_ref_from_cache, is_verbose}; use git::{RepoActions, nostr_url::NostrUrlDecoded}; use ngit::{ client::{self, Params}, @@ -156,7 +156,10 @@ async fn fetching_with_report_for_helper( trusted_maintainer_coordinate: &Nip19Coordinate, ) -> Result<()> { let term = console::Term::stderr(); - term.write_line("nostr: fetching...")?; + let verbose = is_verbose(); + if verbose { + term.write_line("nostr: fetching...")?; + } let (relay_reports, progress_reporter) = client .fetch_all( Some(git_repo_path), @@ -166,10 +169,12 @@ async fn fetching_with_report_for_helper( .await?; let report = consolidate_fetch_reports(relay_reports); if report.to_string().is_empty() { - term.write_line("nostr: no updates")?; + if verbose { + term.write_line("nostr: no updates")?; + } } else { term.write_line(&format!("nostr updates: {report}"))?; } - progress_reporter.clear()?; + let _ = progress_reporter.clear(); Ok(()) } -- cgit v1.2.3