From a0fdc17426afa0e55a2a3b733983bab763226e5a Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Tue, 3 Sep 2024 11:01:14 +0100 Subject: feat(init): https as default clone url protocol so clone urls align to fetch rather than push. see discussion here: nostr:nevent1qvzqqqqx25pzpp59a0hkv5ecm45nrckvmu7pnk0sukssvly33u3wwzquy4v037hcqyxhwumn8ghj7mn0wvhxcmmvqqs2tdha5ymadffrkdprachsz6gsgsy6kc8gkntgq750mfn7u3aeu3g7xt8k9 --- src/sub_commands/init.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/sub_commands') diff --git a/src/sub_commands/init.rs b/src/sub_commands/init.rs index 4958536..5b7e03d 100644 --- a/src/sub_commands/init.rs +++ b/src/sub_commands/init.rs @@ -13,7 +13,7 @@ use crate::{ cli::Cli, cli_interactor::{Interactor, InteractorPrompt, PromptInputParms}, client::{fetching_with_report, get_repo_ref_from_cache, Connect}, - git::{Repo, RepoActions}, + git::{convert_clone_url_to_https, Repo, RepoActions}, login, repo_ref::{ extract_pks, get_repo_config_from_yaml, save_repo_config_to_yaml, @@ -159,11 +159,16 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { Interactor::default() .input( PromptInputParms::default() - .with_prompt("clone url") + .with_prompt("clone url (for fetch)") .with_default(if let Some(repo_ref) = &repo_ref { repo_ref.git_server.clone().join(" ") - } else if let Ok(git_repo) = git_repo.get_origin_url() { - git_repo + } else if let Ok(url) = git_repo.get_origin_url() { + if let Ok(fetch_url) = convert_clone_url_to_https(&url) { + fetch_url + } else { + // local repo or custom protocol + url + } } else { String::new() }), -- cgit v1.2.3