upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/bin/ngit/sub_commands/init.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-09-04 11:32:05 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2024-09-04 14:23:54 +0100
commit771f944af447c202eba045936a36dee71ab797ac (patch)
treee691de4ebc8dde7ac4855e139881ff923bc254ce /src/bin/ngit/sub_commands/init.rs
parent949c6459aa7683453a7160423b689ceadb08954b (diff)
refactor: fix imports, etc based on restructure
move some functions out of ngit and into lib/mod and lib/git_events remove MockConnect from binaries so it is only used in the library. this was done: * mainly because automocks were not being imported from lib into each binary * but also because the these functions were being tested with MockConnect
Diffstat (limited to 'src/bin/ngit/sub_commands/init.rs')
-rw-r--r--src/bin/ngit/sub_commands/init.rs12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs
index 5b7e03d..f7e1ee0 100644
--- a/src/bin/ngit/sub_commands/init.rs
+++ b/src/bin/ngit/sub_commands/init.rs
@@ -4,16 +4,11 @@ use anyhow::{Context, Result};
4use nostr::{nips::nip01::Coordinate, FromBech32, PublicKey, ToBech32}; 4use nostr::{nips::nip01::Coordinate, FromBech32, PublicKey, ToBech32};
5use nostr_sdk::Kind; 5use nostr_sdk::Kind;
6 6
7use super::send::send_events;
8#[cfg(not(test))]
9use crate::client::Client;
10#[cfg(test)]
11use crate::client::MockConnect;
12use crate::{ 7use crate::{
13 cli::Cli, 8 cli::Cli,
14 cli_interactor::{Interactor, InteractorPrompt, PromptInputParms}, 9 cli_interactor::{Interactor, InteractorPrompt, PromptInputParms},
15 client::{fetching_with_report, get_repo_ref_from_cache, Connect}, 10 client::{fetching_with_report, get_repo_ref_from_cache, send_events, Client, Connect},
16 git::{convert_clone_url_to_https, Repo, RepoActions}, 11 git::{nostr_url::convert_clone_url_to_https, Repo, RepoActions},
17 login, 12 login,
18 repo_ref::{ 13 repo_ref::{
19 extract_pks, get_repo_config_from_yaml, save_repo_config_to_yaml, 14 extract_pks, get_repo_config_from_yaml, save_repo_config_to_yaml,
@@ -61,10 +56,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
61 // TODO: check for empty repo 56 // TODO: check for empty repo
62 // TODO: check for existing maintaiers file 57 // TODO: check for existing maintaiers file
63 58
64 #[cfg(not(test))]
65 let mut client = Client::default(); 59 let mut client = Client::default();
66 #[cfg(test)]
67 let mut client = <MockConnect as std::default::Default>::default();
68 60
69 let repo_coordinates = if let Ok(repo_coordinates) = 61 let repo_coordinates = if let Ok(repo_coordinates) =
70 try_and_get_repo_coordinates(&git_repo, &client, false).await 62 try_and_get_repo_coordinates(&git_repo, &client, false).await