upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/list.rs38
1 files changed, 19 insertions, 19 deletions
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::{
9 Repo, RepoActions, 9 Repo, RepoActions,
10 nostr_url::{CloneUrl, NostrUrlDecoded, ServerProtocol}, 10 nostr_url::{CloneUrl, NostrUrlDecoded, ServerProtocol},
11 }, 11 },
12 repo_ref::is_grasp_server_in_list, 12 repo_ref::is_grasp_server_clone_url,
13 utils::{Direction, get_read_protocols_to_try, join_with_and, set_protocol_preference}, 13 utils::{Direction, get_read_protocols_to_try, join_with_and, set_protocol_preference},
14}; 14};
15 15
@@ -18,12 +18,11 @@ pub fn list_from_remotes(
18 git_repo: &Repo, 18 git_repo: &Repo,
19 git_servers: &Vec<String>, 19 git_servers: &Vec<String>,
20 decoded_nostr_url: &NostrUrlDecoded, 20 decoded_nostr_url: &NostrUrlDecoded,
21 grasp_servers: &[String],
22) -> HashMap<String, (HashMap<String, String>, bool)> { 21) -> HashMap<String, (HashMap<String, String>, bool)> {
23 let mut remote_states = HashMap::new(); 22 let mut remote_states = HashMap::new();
24 let mut errors = HashMap::new(); 23 let mut errors = HashMap::new();
25 for url in git_servers { 24 for url in git_servers {
26 let is_grasp_server = is_grasp_server_in_list(url, grasp_servers); 25 let is_grasp_server = is_grasp_server_clone_url(url);
27 match list_from_remote(term, git_repo, url, decoded_nostr_url, is_grasp_server) { 26 match list_from_remote(term, git_repo, url, decoded_nostr_url, is_grasp_server) {
28 Err(error) => { 27 Err(error) => {
29 errors.insert(url, error); 28 errors.insert(url, error);
@@ -72,8 +71,7 @@ pub fn list_from_remote(
72 match res { 71 match res {
73 Ok(state) => { 72 Ok(state) => {
74 remote_state = Some(state); 73 remote_state = Some(state);
75 term.clear_last_lines(1)?; 74 if !is_grasp_server && !failed_protocols.is_empty() {
76 if !failed_protocols.is_empty() {
77 term.write_line( 75 term.write_line(
78 format!( 76 format!(
79 "list: succeeded over {protocol} from {}", 77 "list: succeeded over {protocol} from {}",
@@ -87,27 +85,27 @@ pub fn list_from_remote(
87 break; 85 break;
88 } 86 }
89 Err(error) => { 87 Err(error) => {
90 term.clear_last_lines(1)?; 88 if is_grasp_server {
91 term.write_line(&format!( 89 term.write_line(&format!("list: failed: {error}"))?;
92 "list: {formatted_url} failed over {protocol}{}: {error}", 90 } else {
93 if protocol == &ServerProtocol::Ssh { 91 term.write_line(&format!(
94 if let Some(ssh_key_file) = &decoded_nostr_url.ssh_key_file_path() { 92 "list: {formatted_url} failed over {protocol}{}: {error}",
95 format!(" with ssh key from {ssh_key_file}") 93 if protocol == &ServerProtocol::Ssh {
94 if let Some(ssh_key_file) = &decoded_nostr_url.ssh_key_file_path() {
95 format!(" with ssh key from {ssh_key_file}")
96 } else {
97 String::new()
98 }
96 } else { 99 } else {
97 String::new() 100 String::new()
98 } 101 }
99 } else { 102 ))?;
100 String::new() 103 }
101 }
102 ))?;
103 failed_protocols.push(protocol); 104 failed_protocols.push(protocol);
104 } 105 }
105 } 106 }
106 } 107 }
107 if let Some(remote_state) = remote_state { 108 if let Some(remote_state) = remote_state {
108 if failed_protocols.is_empty() {
109 term.clear_last_lines(1)?;
110 }
111 Ok(remote_state) 109 Ok(remote_state)
112 } else { 110 } else {
113 let error = anyhow!( 111 let error = anyhow!(
@@ -120,7 +118,9 @@ pub fn list_from_remote(
120 "" 118 ""
121 }, 119 },
122 ); 120 );
123 term.write_line(format!("list: {error}").as_str())?; 121 if !is_grasp_server {
122 term.write_line(format!("list: {error}").as_str())?;
123 }
124 Err(error) 124 Err(error)
125 } 125 }
126} 126}