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-08-06 13:13:57 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2025-08-07 17:25:51 +0100
commit8c7a7ca2f538fd9240906f6eb746e55d75a6f4fd (patch)
tree8712630fc61f666ee2211e154668158ae9bed87e /src/bin/ngit
parenta9b2ebf8216be34950e54dd9a446dbdc0c9c744a (diff)
feat(init): use user grasp list for defaults
instead of relying on hardcoded grasp server options. couldn't we look up those selected for other repos for the user instead?
Diffstat (limited to 'src/bin/ngit')
-rw-r--r--src/bin/ngit/sub_commands/init.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs
index 01fcaea..6f3a357 100644
--- a/src/bin/ngit/sub_commands/init.rs
+++ b/src/bin/ngit/sub_commands/init.rs
@@ -266,11 +266,23 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
266 ); 266 );
267 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
268 let empty = options.is_empty(); 268 let empty = options.is_empty();
269 for user_grasp_option in user_ref.grasp_list.urls {
270 // Check if any option contains the user_grasp_option as a substring
271 if !options
272 .iter()
273 .any(|option| option.contains(user_grasp_option.as_str()))
274 {
275 options.push(user_grasp_option.to_string()); // Add if not found
276 selections.push(empty); // mark as selected if no existing grasp otherwise not
277 }
278 }
279
280 let empty = options.is_empty();
269 for fallback in fallback_grasp_servers { 281 for fallback in fallback_grasp_servers {
270 // Check if any option contains the fallback as a substring 282 // Check if any option contains the fallback as a substring
271 if !options.iter().any(|option| option.contains(fallback)) { 283 if !options.iter().any(|option| option.contains(fallback)) {
272 options.push(fallback.clone()); // Add fallback if not found 284 options.push(fallback.clone()); // Add fallback if not found
273 selections.push(empty); // mark as selected if no existing ngit relay otherwise not 285 selections.push(empty); // mark as selected if no existing selections otherwise not
274 } 286 }
275 } 287 }
276 let selected = multi_select_with_custom_value( 288 let selected = multi_select_with_custom_value(