upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/bin/ngit/sub_commands/init.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-07-25 16:12:27 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2025-07-25 16:12:27 +0100
commite89dbc142f5a0a517f197562f5f228681d9aed47 (patch)
tree521dbec8d259f7c982345b40bb128a21795a2012 /src/bin/ngit/sub_commands/init.rs
parent419b827f7c0d826f5eedf574bce0cf9b85cab4ca (diff)
parent0cad465dd3f78bd6c680067d12d396d4782829bf (diff)
Merge branch 'add-PR-feature-to-remote'
Diffstat (limited to 'src/bin/ngit/sub_commands/init.rs')
-rw-r--r--src/bin/ngit/sub_commands/init.rs16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs
index 1242e45..eaaf83d 100644
--- a/src/bin/ngit/sub_commands/init.rs
+++ b/src/bin/ngit/sub_commands/init.rs
@@ -229,7 +229,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
229 .map(std::string::ToString::to_string) 229 .map(std::string::ToString::to_string)
230 .collect::<Vec<String>>() 230 .collect::<Vec<String>>()
231 } else { 231 } else {
232 client.get_fallback_relays().clone() 232 client.get_relay_default_set().clone()
233 } 233 }
234 } else { 234 } else {
235 args.relays.clone() 235 args.relays.clone()
@@ -252,14 +252,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
252 args.blossoms.clone() 252 args.blossoms.clone()
253 }; 253 };
254 254
255 let fallback_grasp_servers = 255 let fallback_grasp_servers = client.get_grasp_default_set();
256 if let Ok(Some(s)) = git_repo.get_git_config_item("nostr.grasp-default-set", None) {
257 s.split(';')
258 .filter_map(|url| normalize_grasp_server_url(url).ok()) // Attempt to parse and filter out errors
259 .collect()
260 } else {
261 vec!["relay.ngit.dev".to_string(), "gitnostr.com".to_string()]
262 };
263 256
264 let selected_grasp_servers = if has_server_and_relay_flags { 257 let selected_grasp_servers = if has_server_and_relay_flags {
265 // ignore so a script running `ngit init` can contiue without prompts 258 // ignore so a script running `ngit init` can contiue without prompts
@@ -269,14 +262,13 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
269 repo_ref.as_ref(), 262 repo_ref.as_ref(),
270 &args.relays, 263 &args.relays,
271 &args.clone_url, 264 &args.clone_url,
272 &args.blossoms,
273 &identifier, 265 &identifier,
274 ); 266 );
275 let mut selections: Vec<bool> = vec![true; options.len()]; // Initialize selections based on existing options 267 let mut selections: Vec<bool> = vec![true; options.len()]; // Initialize selections based on existing options
276 let empty = options.is_empty(); 268 let empty = options.is_empty();
277 for fallback in fallback_grasp_servers { 269 for fallback in fallback_grasp_servers {
278 // Check if any option contains the fallback as a substring 270 // Check if any option contains the fallback as a substring
279 if !options.iter().any(|option| option.contains(&fallback)) { 271 if !options.iter().any(|option| option.contains(fallback)) {
280 options.push(fallback.clone()); // Add fallback if not found 272 options.push(fallback.clone()); // Add fallback if not found
281 selections.push(empty); // mark as selected if no existing ngit relay otherwise not 273 selections.push(empty); // mark as selected if no existing ngit relay otherwise not
282 } 274 }
@@ -464,7 +456,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
464 let mut selections: Vec<bool> = vec![true; options.len()]; 456 let mut selections: Vec<bool> = vec![true; options.len()];
465 457
466 // add fallback relays as options 458 // add fallback relays as options
467 for relay in client.get_fallback_relays().clone() { 459 for relay in client.get_relay_default_set().clone() {
468 if !options.iter().any(|r| r.contains(&relay)) 460 if !options.iter().any(|r| r.contains(&relay))
469 && !formatted_selected_grasp_servers 461 && !formatted_selected_grasp_servers
470 .iter() 462 .iter()