From 771f944af447c202eba045936a36dee71ab797ac Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 4 Sep 2024 11:32:05 +0100 Subject: 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 --- src/bin/ngit/sub_commands/push.rs | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) (limited to 'src/bin/ngit/sub_commands/push.rs') 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 @@ use anyhow::{bail, Context, Result}; +use ngit::{client::send_events, git_events::tag_value}; -#[cfg(not(test))] -use crate::client::Client; -#[cfg(test)] -use crate::client::MockConnect; use crate::{ cli::Cli, - client::{fetching_with_report, get_repo_ref_from_cache, Connect}, - git::{str_to_sha1, Repo, RepoActions}, + client::{ + fetching_with_report, get_all_proposal_patch_events_from_cache, + get_proposals_and_revisions_from_cache, get_repo_ref_from_cache, Client, Connect, + }, + git::{identify_ahead_behind, str_to_sha1, Repo, RepoActions}, + git_events::{ + event_is_revision_root, event_to_cover_letter, generate_patch_event, + get_commit_id_from_patch, get_most_recent_patch_with_ancestors, + }, login, repo_ref::get_repo_coordinates, - sub_commands::{ - self, - list::{ - get_all_proposal_patch_events_from_cache, get_commit_id_from_patch, - get_most_recent_patch_with_ancestors, get_proposals_and_revisions_from_cache, - tag_value, - }, - send::{ - event_is_revision_root, event_to_cover_letter, generate_patch_event, - identify_ahead_behind, send_events, - }, - }, + sub_commands, }; #[derive(Debug, clap::Args)] @@ -51,10 +44,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { if branch_name == main_or_master_branch_name { bail!("checkout a branch associated with a proposal first") } - #[cfg(not(test))] let mut client = Client::default(); - #[cfg(test)] - let mut client = ::default(); let repo_coordinates = get_repo_coordinates(&git_repo, &client).await?; -- cgit v1.2.3