upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/bin/ngit
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-07-23 13:53:18 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2025-07-23 13:53:18 +0100
commitdd5300b301292c3944aad4dcdecf4802307c7ea2 (patch)
treef7e8ba79bd97810da039da9b030e72067ceeee03 /src/bin/ngit
parentf7299cc5fd2276db8d9bb7778c34ddbe5b3a8e48 (diff)
refactor: add fallback grasp servers to client
so that they can be used as part of push and send
Diffstat (limited to 'src/bin/ngit')
-rw-r--r--src/bin/ngit/sub_commands/init.rs11
1 files changed, 2 insertions, 9 deletions
diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs
index 86d7f8a..52e43e9 100644
--- a/src/bin/ngit/sub_commands/init.rs
+++ b/src/bin/ngit/sub_commands/init.rs
@@ -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_fallback_grasp_servers();
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
@@ -275,7 +268,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
275 let empty = options.is_empty(); 268 let empty = options.is_empty();
276 for fallback in fallback_grasp_servers { 269 for fallback in fallback_grasp_servers {
277 // Check if any option contains the fallback as a substring 270 // Check if any option contains the fallback as a substring
278 if !options.iter().any(|option| option.contains(&fallback)) { 271 if !options.iter().any(|option| option.contains(fallback)) {
279 options.push(fallback.clone()); // Add fallback if not found 272 options.push(fallback.clone()); // Add fallback if not found
280 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
281 } 274 }