upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/bin/ngit/sub_commands
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-05-24 20:23:39 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2025-05-24 20:30:55 +0100
commit557d9295e3fc6145073459da94905765de53be1e (patch)
tree6f0e49b4cd22e30f1d366060df3ee45f3c210efc /src/bin/ngit/sub_commands
parent0f34bbdb452f287a03167abe24011bc35cc85c26 (diff)
feat(init): make default ngit-relays configurable
make the default set of ngit-relays configurable
Diffstat (limited to 'src/bin/ngit/sub_commands')
-rw-r--r--src/bin/ngit/sub_commands/init.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs
index f348c0d..1d9fda0 100644
--- a/src/bin/ngit/sub_commands/init.rs
+++ b/src/bin/ngit/sub_commands/init.rs
@@ -252,6 +252,15 @@ 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_ngit_relays =
256 if let Ok(Some(s)) = git_repo.get_git_config_item("nostr.ngit-relay-default-set", None) {
257 s.split(';')
258 .filter_map(|url| normalize_ngit_relay_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
255 let selected_ngit_relays = if has_server_and_relay_flags { 264 let selected_ngit_relays = if has_server_and_relay_flags {
256 // ignore so a script running `ngit init` can contiue without prompts 265 // ignore so a script running `ngit init` can contiue without prompts
257 vec![] 266 vec![]
@@ -265,8 +274,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
265 ); 274 );
266 let mut selections: Vec<bool> = vec![true; options.len()]; // Initialize selections based on existing options 275 let mut selections: Vec<bool> = vec![true; options.len()]; // Initialize selections based on existing options
267 let empty = options.is_empty(); 276 let empty = options.is_empty();
268 let fallbacks = vec!["relay.ngit.dev".to_string(), "gitnostr.com".to_string()]; 277 for fallback in fallback_ngit_relays {
269 for fallback in fallbacks {
270 // Check if any option contains the fallback as a substring 278 // Check if any option contains the fallback as a substring
271 if !options.iter().any(|option| option.contains(&fallback)) { 279 if !options.iter().any(|option| option.contains(&fallback)) {
272 options.push(fallback.clone()); // Add fallback if not found 280 options.push(fallback.clone()); // Add fallback if not found