From a0d147ba1f14468924f291c3bcf51b25329f4204 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 31 Oct 2024 09:32:38 +0000 Subject: fix(init): dont err when nostr remote and no ann when the user has set a remote to a nostr url but hasn't initiated the repository on nostr - dont error but instead use the identifier in the remote --- src/bin/ngit/sub_commands/init.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs index f7e1ee0..8f9ff0d 100644 --- a/src/bin/ngit/sub_commands/init.rs +++ b/src/bin/ngit/sub_commands/init.rs @@ -66,9 +66,13 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { None }; - let repo_ref = if let Some(repo_coordinates) = repo_coordinates { + let repo_ref = if let Some(repo_coordinates) = repo_coordinates.clone() { fetching_with_report(git_repo_path, &client, &repo_coordinates).await?; - Some(get_repo_ref_from_cache(git_repo_path, &repo_coordinates).await?) + if let Ok(repo_ref) = get_repo_ref_from_cache(git_repo_path, &repo_coordinates).await { + Some(repo_ref) + } else { + None + } } else { None }; @@ -95,6 +99,12 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { .with_prompt("name") .with_default(if let Some(repo_ref) = &repo_ref { repo_ref.name.clone() + } else if let Some(repo_coordinates) = repo_coordinates.clone() { + if let Some(coordinate) = repo_coordinates.iter().next() { + coordinate.identifier.clone() + } else { + String::new() + } } else { String::new() }), @@ -108,6 +118,12 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { .with_prompt("identifier") .with_default(if let Some(repo_ref) = &repo_ref { repo_ref.identifier.clone() + } else if let Some(repo_coordinates) = repo_coordinates.clone() { + if let Some(coordinate) = repo_coordinates.iter().next() { + coordinate.identifier.clone() + } else { + String::new() + } } else { let fallback = name .clone() -- cgit v1.2.3