upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/bin/git_remote_nostr/list.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-05-23 10:01:29 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2025-05-23 10:01:29 +0100
commit686604665395385600ef8f1b5238a775249552a1 (patch)
tree56a4c7a956e14dfbcdd4a518096968abc69583a6 /src/bin/git_remote_nostr/list.rs
parentcc9a3a1d8526373625246504f72f338fd89c8d8b (diff)
feat: only try http(s) for ngit-relays
otherwise it tries all the protocols and reprots on each
Diffstat (limited to 'src/bin/git_remote_nostr/list.rs')
-rw-r--r--src/bin/git_remote_nostr/list.rs21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/bin/git_remote_nostr/list.rs b/src/bin/git_remote_nostr/list.rs
index 2d233ae..bf16f89 100644
--- a/src/bin/git_remote_nostr/list.rs
+++ b/src/bin/git_remote_nostr/list.rs
@@ -13,7 +13,7 @@ use ngit::{
13 }, 13 },
14 git_events::event_to_cover_letter, 14 git_events::event_to_cover_letter,
15 login::get_curent_user, 15 login::get_curent_user,
16 repo_ref, 16 repo_ref::{self, is_ngit_relay},
17}; 17};
18use nostr_sdk::hashes::sha1::Hash as Sha1Hash; 18use nostr_sdk::hashes::sha1::Hash as Sha1Hash;
19use repo_ref::RepoRef; 19use repo_ref::RepoRef;
@@ -41,6 +41,7 @@ pub async fn run_list(
41 git_repo, 41 git_repo,
42 &repo_ref.git_server, 42 &repo_ref.git_server,
43 &repo_ref.to_nostr_git_url(&None), 43 &repo_ref.to_nostr_git_url(&None),
44 &repo_ref.ngit_relays(),
44 ); 45 );
45 46
46 let mut state = if let Some(nostr_state) = nostr_state { 47 let mut state = if let Some(nostr_state) = nostr_state {
@@ -131,6 +132,7 @@ async fn get_open_and_draft_proposals_state(
131 git_server_url, 132 git_server_url,
132 &repo_ref.to_nostr_git_url(&None), 133 &repo_ref.to_nostr_git_url(&None),
133 term, 134 term,
135 is_ngit_relay(git_server_url, &repo_ref.ngit_relays()),
134 ) 136 )
135 .is_ok() 137 .is_ok()
136 { 138 {
@@ -174,12 +176,19 @@ pub fn list_from_remotes(
174 term: &console::Term, 176 term: &console::Term,
175 git_repo: &Repo, 177 git_repo: &Repo,
176 git_servers: &Vec<String>, 178 git_servers: &Vec<String>,
177 decoded_nostr_url: &NostrUrlDecoded, // Add this parameter 179 decoded_nostr_url: &NostrUrlDecoded,
180 ngit_relays: &[String],
178) -> HashMap<String, HashMap<String, String>> { 181) -> HashMap<String, HashMap<String, String>> {
179 let mut remote_states = HashMap::new(); 182 let mut remote_states = HashMap::new();
180 let mut errors = HashMap::new(); 183 let mut errors = HashMap::new();
181 for url in git_servers { 184 for url in git_servers {
182 match list_from_remote(term, git_repo, url, decoded_nostr_url) { 185 match list_from_remote(
186 term,
187 git_repo,
188 url,
189 decoded_nostr_url,
190 is_ngit_relay(url, ngit_relays),
191 ) {
183 Err(error) => { 192 Err(error) => {
184 errors.insert(url, error); 193 errors.insert(url, error);
185 } 194 }
@@ -195,10 +204,12 @@ pub fn list_from_remote(
195 term: &console::Term, 204 term: &console::Term,
196 git_repo: &Repo, 205 git_repo: &Repo,
197 git_server_url: &str, 206 git_server_url: &str,
198 decoded_nostr_url: &NostrUrlDecoded, // Add this parameter 207 decoded_nostr_url: &NostrUrlDecoded,
208 is_ngit_relay: bool,
199) -> Result<HashMap<String, String>> { 209) -> Result<HashMap<String, String>> {
200 let server_url = git_server_url.parse::<CloneUrl>()?; 210 let server_url = git_server_url.parse::<CloneUrl>()?;
201 let protocols_to_attempt = get_read_protocols_to_try(git_repo, &server_url, decoded_nostr_url); 211 let protocols_to_attempt =
212 get_read_protocols_to_try(git_repo, &server_url, decoded_nostr_url, is_ngit_relay);
202 213
203 let mut failed_protocols = vec![]; 214 let mut failed_protocols = vec![];
204 let mut remote_state: Option<HashMap<String, String>> = None; 215 let mut remote_state: Option<HashMap<String, String>> = None;