upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/bin/ngit/sub_commands/push.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/push.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/push.rs')
-rw-r--r--src/bin/ngit/sub_commands/push.rs32
1 files changed, 11 insertions, 21 deletions
diff --git a/src/bin/ngit/sub_commands/push.rs b/src/bin/ngit/sub_commands/push.rs
index 7a82c7a..79065fc 100644
--- a/src/bin/ngit/sub_commands/push.rs
+++ b/src/bin/ngit/sub_commands/push.rs
@@ -1,27 +1,20 @@
1use anyhow::{bail, Context, Result}; 1use anyhow::{bail, Context, Result};
2use ngit::{client::send_events, git_events::tag_value};
2 3
3#[cfg(not(test))]
4use crate::client::Client;
5#[cfg(test)]
6use crate::client::MockConnect;
7use crate::{ 4use crate::{
8 cli::Cli, 5 cli::Cli,
9 client::{fetching_with_report, get_repo_ref_from_cache, Connect}, 6 client::{
10 git::{str_to_sha1, Repo, RepoActions}, 7 fetching_with_report, get_all_proposal_patch_events_from_cache,
8 get_proposals_and_revisions_from_cache, get_repo_ref_from_cache, Client, Connect,
9 },
10 git::{identify_ahead_behind, str_to_sha1, Repo, RepoActions},
11 git_events::{
12 event_is_revision_root, event_to_cover_letter, generate_patch_event,
13 get_commit_id_from_patch, get_most_recent_patch_with_ancestors,
14 },
11 login, 15 login,
12 repo_ref::get_repo_coordinates, 16 repo_ref::get_repo_coordinates,
13 sub_commands::{ 17 sub_commands,
14 self,
15 list::{
16 get_all_proposal_patch_events_from_cache, get_commit_id_from_patch,
17 get_most_recent_patch_with_ancestors, get_proposals_and_revisions_from_cache,
18 tag_value,
19 },
20 send::{
21 event_is_revision_root, event_to_cover_letter, generate_patch_event,
22 identify_ahead_behind, send_events,
23 },
24 },
25}; 18};
26 19
27#[derive(Debug, clap::Args)] 20#[derive(Debug, clap::Args)]
@@ -51,10 +44,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
51 if branch_name == main_or_master_branch_name { 44 if branch_name == main_or_master_branch_name {
52 bail!("checkout a branch associated with a proposal first") 45 bail!("checkout a branch associated with a proposal first")
53 } 46 }
54 #[cfg(not(test))]
55 let mut client = Client::default(); 47 let mut client = Client::default();
56 #[cfg(test)]
57 let mut client = <MockConnect as std::default::Default>::default();
58 48
59 let repo_coordinates = get_repo_coordinates(&git_repo, &client).await?; 49 let repo_coordinates = get_repo_coordinates(&git_repo, &client).await?;
60 50