upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/client.rs33
-rw-r--r--src/lib/list.rs26
2 files changed, 29 insertions, 30 deletions
diff --git a/src/lib/client.rs b/src/lib/client.rs
index 4f5c341..1cb1a4a 100644
--- a/src/lib/client.rs
+++ b/src/lib/client.rs
@@ -455,7 +455,6 @@ impl Connect for Client {
455 let progress_reporter_clone = progress_reporter.clone(); 455 let progress_reporter_clone = progress_reporter.clone();
456 let total_relays_clone = total_relays; 456 let total_relays_clone = total_relays;
457 async move { 457 async move {
458 let dim = Style::new().color256(247);
459 let relay_column_width = request.relay_column_width; 458 let relay_column_width = request.relay_column_width;
460 459
461 let relay_url = request 460 let relay_url = request
@@ -467,10 +466,10 @@ impl Connect for Client {
467 let pb = progress_reporter_clone.add( 466 let pb = progress_reporter_clone.add(
468 ProgressBar::new(1) 467 ProgressBar::new(1)
469 .with_prefix( 468 .with_prefix(
470 dim.apply_to(format!( 469 format!(
471 "{: <relay_column_width$} connecting", 470 "{: <relay_column_width$} connecting",
472 &relay_url 471 &relay_url
473 )) 472 )
474 .to_string(), 473 .to_string(),
475 ) 474 )
476 .with_style(pb_style(current_timeout_clone.clone())?), 475 .with_style(pb_style(current_timeout_clone.clone())?),
@@ -681,6 +680,7 @@ impl Connect for Client {
681 format!("fetching... updates: {report}") 680 format!("fetching... updates: {report}")
682 }, 681 },
683 )) 682 ))
683 .for_stderr()
684 .to_string(), 684 .to_string(),
685 ); 685 );
686 } 686 }
@@ -713,18 +713,16 @@ impl Connect for Client {
713 } 713 }
714 if let Some(pb) = pb { 714 if let Some(pb) = pb {
715 pb.set_style(pb_after_style(true)); 715 pb.set_style(pb_after_style(true));
716 pb.set_prefix( 716 pb.set_prefix(format!(
717 dim.apply_to(format!( 717 "{} {}",
718 "{: <relay_column_width$} {}", 718 dim.apply_to(format!("{: <relay_column_width$}", &relay_url))
719 relay_url, 719 .for_stderr(),
720 if report.to_string().is_empty() { 720 if report.to_string().is_empty() {
721 "no new events".to_string() 721 "no new events".to_string()
722 } else { 722 } else {
723 format!("new events: {report}") 723 format!("new events: {report}")
724 }, 724 },
725 )) 725 ));
726 .to_string(),
727 );
728 pb.finish_with_message(""); 726 pb.finish_with_message("");
729 } 727 }
730 Ok(report) 728 Ok(report)
@@ -805,7 +803,7 @@ async fn get_events_of(
805 pb.set_message(format!( 803 pb.set_message(format!(
806 "{} {}", 804 "{} {}",
807 console::style("connection failed").for_stderr().red(), 805 console::style("connection failed").for_stderr().red(),
808 dim.apply_to(retry_msg) 806 dim.apply_to(retry_msg).for_stderr()
809 )); 807 ));
810 } 808 }
811 tokio::time::sleep(retry_delay).await; 809 tokio::time::sleep(retry_delay).await;
@@ -831,7 +829,7 @@ async fn get_events_of(
831 pb.set_message(format!( 829 pb.set_message(format!(
832 "{} {}", 830 "{} {}",
833 console::style("connection failed").for_stderr().red(), 831 console::style("connection failed").for_stderr().red(),
834 dim.apply_to(retry_msg) 832 dim.apply_to(retry_msg).for_stderr()
835 )); 833 ));
836 } 834 }
837 835
@@ -1113,6 +1111,7 @@ fn pb_style(current_timeout: Arc<AtomicU64>) -> Result<ProgressStyle> {
1113 w, 1111 w,
1114 "{}", 1112 "{}",
1115 dim.apply_to(format!("timeout in {:.1}s", timeout - elapsed)) 1113 dim.apply_to(format!("timeout in {:.1}s", timeout - elapsed))
1114 .for_stderr()
1116 ) 1115 )
1117 .unwrap(); 1116 .unwrap();
1118 } 1117 }
diff --git a/src/lib/list.rs b/src/lib/list.rs
index 69da792..cb26c19 100644
--- a/src/lib/list.rs
+++ b/src/lib/list.rs
@@ -11,7 +11,6 @@ use std::{
11 11
12use anyhow::{Result, anyhow}; 12use anyhow::{Result, anyhow};
13use auth_git2::GitAuthenticator; 13use auth_git2::GitAuthenticator;
14use console::Style;
15use futures::stream::{self, StreamExt}; 14use futures::stream::{self, StreamExt};
16use indicatif::{MultiProgress, ProgressBar, ProgressState, ProgressStyle}; 15use indicatif::{MultiProgress, ProgressBar, ProgressState, ProgressStyle};
17use nostr::hashes::sha1::Hash as Sha1Hash; 16use nostr::hashes::sha1::Hash as Sha1Hash;
@@ -140,9 +139,8 @@ pub async fn list_from_remotes(
140 let current_timeout_clone = current_timeout.clone(); 139 let current_timeout_clone = current_timeout.clone();
141 let progress_reporter_clone = progress_reporter.clone(); 140 let progress_reporter_clone = progress_reporter.clone();
142 let decoded_nostr_url = decoded_nostr_url.clone(); 141 let decoded_nostr_url = decoded_nostr_url.clone();
143 142
144 async move { 143 async move {
145 let dim = Style::new().color256(247);
146 let server_name = get_short_git_server_name(&url); 144 let server_name = get_short_git_server_name(&url);
147 145
148 let pb = if std::env::var("NGITTEST").is_err() { 146 let pb = if std::env::var("NGITTEST").is_err() {
@@ -151,10 +149,12 @@ pub async fn list_from_remotes(
151 let pb = progress_reporter_clone.add( 149 let pb = progress_reporter_clone.add(
152 ProgressBar::new(1) 150 ProgressBar::new(1)
153 .with_prefix( 151 .with_prefix(
154 dim.apply_to(format!( 152 console::style(format!(
155 "{: <server_column_width$} connecting", 153 "{: <server_column_width$} connecting",
156 &server_name 154 &server_name
157 )) 155 ))
156 .for_stderr()
157 .yellow()
158 .to_string(), 158 .to_string(),
159 ) 159 )
160 .with_style(style), 160 .with_style(style),
@@ -177,9 +177,9 @@ pub async fn list_from_remotes(
177 if let Some(pb) = pb { 177 if let Some(pb) = pb {
178 pb.set_style(git_server_pb_after_style(false)); 178 pb.set_style(git_server_pb_after_style(false));
179 pb.set_prefix( 179 pb.set_prefix(
180 Style::new() 180 console::style(format!("{: <server_column_width$}", server_name))
181 .color256(247) 181 .for_stderr()
182 .apply_to(format!("{: <server_column_width$}", server_name)) 182 .dim()
183 .to_string(), 183 .to_string(),
184 ); 184 );
185 pb.finish_with_message( 185 pb.finish_with_message(
@@ -196,7 +196,7 @@ pub async fn list_from_remotes(
196 let url_clone = url.clone(); 196 let url_clone = url.clone();
197 let decoded_nostr_url_clone = decoded_nostr_url.clone(); 197 let decoded_nostr_url_clone = decoded_nostr_url.clone();
198 let pb_clone = pb.clone(); 198 let pb_clone = pb.clone();
199 199
200 let list_future = async move { 200 let list_future = async move {
201 match tokio::task::spawn_blocking(move || { 201 match tokio::task::spawn_blocking(move || {
202 // Re-open repo in blocking thread (git2::Repository is not Send) 202 // Re-open repo in blocking thread (git2::Repository is not Send)
@@ -204,7 +204,7 @@ pub async fn list_from_remotes(
204 Some(path) => Repo::from_path(&path).ok(), 204 Some(path) => Repo::from_path(&path).ok(),
205 None => None, 205 None => None,
206 }; 206 };
207 207
208 match git_repo { 208 match git_repo {
209 Some(ref repo) => list_from_remote_sync( 209 Some(ref repo) => list_from_remote_sync(
210 repo, 210 repo,
@@ -283,7 +283,7 @@ pub async fn list_from_remotes(
283 temp_states.insert(url.clone(), (state.clone(), is_grasp_server)); 283 temp_states.insert(url.clone(), (state.clone(), is_grasp_server));
284 let remote_issues = identify_remote_sync_issues(git_repo, nostr_state, &temp_states); 284 let remote_issues = identify_remote_sync_issues(git_repo, nostr_state, &temp_states);
285 let warnings = generate_remote_sync_warnings(&remote_issues, &temp_states); 285 let warnings = generate_remote_sync_warnings(&remote_issues, &temp_states);
286 286
287 if warnings.is_empty() { 287 if warnings.is_empty() {
288 "in sync".to_string() 288 "in sync".to_string()
289 } else { 289 } else {
@@ -313,9 +313,9 @@ pub async fn list_from_remotes(
313 if let Some(pb) = pb { 313 if let Some(pb) = pb {
314 pb.set_style(git_server_pb_after_style(is_success)); 314 pb.set_style(git_server_pb_after_style(is_success));
315 pb.set_prefix( 315 pb.set_prefix(
316 Style::new() 316 console::style(format!("{: <server_column_width$}", &server_name))
317 .color256(247) 317 .for_stderr()
318 .apply_to(format!("{: <server_column_width$}", &server_name)) 318 .dim()
319 .to_string(), 319 .to_string(),
320 ); 320 );
321 pb.finish_with_message(message_style.to_string()); 321 pb.finish_with_message(message_style.to_string());