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:
Diffstat (limited to 'src/bin/ngit/sub_commands')
-rw-r--r--src/bin/ngit/sub_commands/init.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs
index 70a2cd9..5c090ae 100644
--- a/src/bin/ngit/sub_commands/init.rs
+++ b/src/bin/ngit/sub_commands/init.rs
@@ -10,6 +10,7 @@ use anyhow::{Context, Result, bail};
10use console::Style; 10use console::Style;
11use dialoguer::theme::{ColorfulTheme, Theme}; 11use dialoguer::theme::{ColorfulTheme, Theme};
12use ngit::{ 12use ngit::{
13 UrlWithoutSlash,
13 cli_interactor::{PromptChoiceParms, PromptConfirmParms, PromptMultiChoiceParms}, 14 cli_interactor::{PromptChoiceParms, PromptConfirmParms, PromptMultiChoiceParms},
14 client::{Params, send_events}, 15 client::{Params, send_events},
15 git::nostr_url::{CloneUrl, NostrUrlDecoded}, 16 git::nostr_url::{CloneUrl, NostrUrlDecoded},
@@ -231,7 +232,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
231 repo_ref 232 repo_ref
232 .blossoms 233 .blossoms
233 .iter() 234 .iter()
234 .map(std::string::ToString::to_string) 235 .map(UrlWithoutSlash::to_string_without_trailing_slash)
235 .collect::<Vec<String>>() 236 .collect::<Vec<String>>()
236 // } else if user_ref.blossoms.read().is_empty() { 237 // } else if user_ref.blossoms.read().is_empty() {
237 // client.get_fallback_relays().clone() 238 // client.get_fallback_relays().clone()
@@ -290,7 +291,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
290 } 291 }
291 } 292 }
292 if args.blossoms.is_empty() { 293 if args.blossoms.is_empty() {
293 let blossom = format_ngit_blossom_url_as_relay_url(ngit_relay)?; 294 let blossom = format_ngit_relay_url_as_blossom_url(ngit_relay)?;
294 if !blossoms_defaults.contains(&blossom) { 295 if !blossoms_defaults.contains(&blossom) {
295 blossoms_defaults.push(blossom); 296 blossoms_defaults.push(blossom);
296 } 297 }
@@ -483,8 +484,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
483 blossoms_defaults, 484 blossoms_defaults,
484 selections, 485 selections,
485 |s| { 486 |s| {
486 Url::parse(s) 487 format_ngit_relay_url_as_blossom_url(s)
487 .map(|_| s.to_string())
488 .context(format!("Invalid blossom URL format: {s}")) 488 .context(format!("Invalid blossom URL format: {s}"))
489 }, 489 },
490 )?; 490 )?;
@@ -974,10 +974,10 @@ fn format_ngit_relay_url_as_relay_url(url: &str) -> Result<String> {
974 Ok(format!("wss://{ngit_relay_url}")) 974 Ok(format!("wss://{ngit_relay_url}"))
975} 975}
976 976
977fn format_ngit_blossom_url_as_relay_url(url: &str) -> Result<String> { 977fn format_ngit_relay_url_as_blossom_url(url: &str) -> Result<String> {
978 let ngit_relay_url = normalize_ngit_relay_url(url)?; 978 let ngit_relay_url = normalize_ngit_relay_url(url)?;
979 if ngit_relay_url.contains("http://") { 979 if ngit_relay_url.contains("http://") {
980 return Ok(ngit_relay_url.to_string()); 980 return Ok(ngit_relay_url);
981 } 981 }
982 Ok(format!("https://{ngit_relay_url}")) 982 Ok(format!("https://{ngit_relay_url}"))
983} 983}