upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/git_remote_nostr/list.rs1
-rw-r--r--src/bin/git_remote_nostr/push.rs1
-rw-r--r--src/bin/ngit/sub_commands/sync.rs9
-rw-r--r--src/lib/list.rs38
4 files changed, 21 insertions, 28 deletions
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(
31 git_repo, 31 git_repo,
32 &repo_ref.git_server, 32 &repo_ref.git_server,
33 &repo_ref.to_nostr_git_url(&None), 33 &repo_ref.to_nostr_git_url(&None),
34 &repo_ref.grasp_servers(),
35 ); 34 );
36 35
37 let mut state = if let Some(nostr_state) = nostr_state { 36 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(
75 git_repo, 75 git_repo,
76 &repo_ref.git_server, 76 &repo_ref.git_server,
77 &repo_ref.to_nostr_git_url(&None), 77 &repo_ref.to_nostr_git_url(&None),
78 &repo_ref.grasp_servers(),
79 ) 78 )
80 }); 79 });
81 80
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<()> {
77 77
78 let term = console::Term::stderr(); 78 let term = console::Term::stderr();
79 79
80 let remote_states = list_from_remotes( 80 let remote_states =
81 &term, 81 list_from_remotes(&term, &git_repo, &repo_ref.git_server, &decoded_nostr_url);
82 &git_repo,
83 &repo_ref.git_server,
84 &decoded_nostr_url,
85 &repo_ref.grasp_servers(),
86 );
87 82
88 let missing_refs = 83 let missing_refs =
89 fetch_missing_refs(&git_repo, &nostr_state, &remote_states, &decoded_nostr_url); 84 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::{
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}