diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-09-04 11:32:05 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-09-04 14:23:54 +0100 |
| commit | 771f944af447c202eba045936a36dee71ab797ac (patch) | |
| tree | e691de4ebc8dde7ac4855e139881ff923bc254ce /src/bin/ngit/sub_commands/pull.rs | |
| parent | 949c6459aa7683453a7160423b689ceadb08954b (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/pull.rs')
| -rw-r--r-- | src/bin/ngit/sub_commands/pull.rs | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/bin/ngit/sub_commands/pull.rs b/src/bin/ngit/sub_commands/pull.rs index e33a744..b66422d 100644 --- a/src/bin/ngit/sub_commands/pull.rs +++ b/src/bin/ngit/sub_commands/pull.rs | |||
| @@ -1,21 +1,16 @@ | |||
| 1 | use anyhow::{bail, Context, Result}; | 1 | use anyhow::{bail, Context, Result}; |
| 2 | 2 | ||
| 3 | use super::{ | ||
| 4 | list::{ | ||
| 5 | get_all_proposal_patch_events_from_cache, get_commit_id_from_patch, | ||
| 6 | get_proposals_and_revisions_from_cache, tag_value, | ||
| 7 | }, | ||
| 8 | send::event_to_cover_letter, | ||
| 9 | }; | ||
| 10 | #[cfg(test)] | ||
| 11 | use crate::client::MockConnect; | ||
| 12 | #[cfg(not(test))] | ||
| 13 | use crate::client::{Client, Connect}; | ||
| 14 | use crate::{ | 3 | use crate::{ |
| 15 | client::{fetching_with_report, get_repo_ref_from_cache}, | 4 | client::{ |
| 5 | fetching_with_report, get_all_proposal_patch_events_from_cache, | ||
| 6 | get_proposals_and_revisions_from_cache, get_repo_ref_from_cache, Client, Connect, | ||
| 7 | }, | ||
| 16 | git::{str_to_sha1, Repo, RepoActions}, | 8 | git::{str_to_sha1, Repo, RepoActions}, |
| 9 | git_events::{ | ||
| 10 | event_is_revision_root, event_to_cover_letter, get_commit_id_from_patch, | ||
| 11 | get_most_recent_patch_with_ancestors, tag_value, | ||
| 12 | }, | ||
| 17 | repo_ref::get_repo_coordinates, | 13 | repo_ref::get_repo_coordinates, |
| 18 | sub_commands::{list::get_most_recent_patch_with_ancestors, send::event_is_revision_root}, | ||
| 19 | }; | 14 | }; |
| 20 | 15 | ||
| 21 | #[allow(clippy::too_many_lines)] | 16 | #[allow(clippy::too_many_lines)] |
| @@ -34,10 +29,7 @@ pub async fn launch() -> Result<()> { | |||
| 34 | if branch_name == main_or_master_branch_name { | 29 | if branch_name == main_or_master_branch_name { |
| 35 | bail!("checkout a branch associated with a proposal first") | 30 | bail!("checkout a branch associated with a proposal first") |
| 36 | } | 31 | } |
| 37 | #[cfg(not(test))] | ||
| 38 | let client = Client::default(); | 32 | let client = Client::default(); |
| 39 | #[cfg(test)] | ||
| 40 | let client = <MockConnect as std::default::Default>::default(); | ||
| 41 | 33 | ||
| 42 | let repo_coordinates = get_repo_coordinates(&git_repo, &client).await?; | 34 | let repo_coordinates = get_repo_coordinates(&git_repo, &client).await?; |
| 43 | 35 | ||