diff options
Diffstat (limited to 'src/sub_commands')
| -rw-r--r-- | src/sub_commands/claim.rs | 2 | ||||
| -rw-r--r-- | src/sub_commands/list.rs (renamed from src/sub_commands/prs/list.rs) | 10 | ||||
| -rw-r--r-- | src/sub_commands/mod.rs | 3 | ||||
| -rw-r--r-- | src/sub_commands/prs/mod.rs | 25 | ||||
| -rw-r--r-- | src/sub_commands/pull.rs | 2 | ||||
| -rw-r--r-- | src/sub_commands/push.rs | 4 | ||||
| -rw-r--r-- | src/sub_commands/send.rs (renamed from src/sub_commands/prs/create.rs) | 7 |
7 files changed, 11 insertions, 42 deletions
diff --git a/src/sub_commands/claim.rs b/src/sub_commands/claim.rs index d3a80c8..a95021d 100644 --- a/src/sub_commands/claim.rs +++ b/src/sub_commands/claim.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | use anyhow::{Context, Result}; | 1 | use anyhow::{Context, Result}; |
| 2 | 2 | ||
| 3 | use super::prs::create::send_events; | 3 | use super::send::send_events; |
| 4 | #[cfg(not(test))] | 4 | #[cfg(not(test))] |
| 5 | use crate::client::Client; | 5 | use crate::client::Client; |
| 6 | #[cfg(test)] | 6 | #[cfg(test)] |
diff --git a/src/sub_commands/prs/list.rs b/src/sub_commands/list.rs index d4dcfec..49cbf6d 100644 --- a/src/sub_commands/prs/list.rs +++ b/src/sub_commands/list.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | use anyhow::{bail, Context, Result}; | 1 | use anyhow::{bail, Context, Result}; |
| 2 | 2 | ||
| 3 | use super::create::event_is_patch_set_root; | 3 | use super::send::event_is_patch_set_root; |
| 4 | #[cfg(not(test))] | 4 | #[cfg(not(test))] |
| 5 | use crate::client::Client; | 5 | use crate::client::Client; |
| 6 | #[cfg(test)] | 6 | #[cfg(test)] |
| @@ -10,7 +10,7 @@ use crate::{ | |||
| 10 | client::Connect, | 10 | client::Connect, |
| 11 | git::{Repo, RepoActions}, | 11 | git::{Repo, RepoActions}, |
| 12 | repo_ref::{self, RepoRef, REPO_REF_KIND}, | 12 | repo_ref::{self, RepoRef, REPO_REF_KIND}, |
| 13 | sub_commands::prs::create::{event_is_cover_letter, event_to_cover_letter, PATCH_KIND}, | 13 | sub_commands::send::{event_is_cover_letter, event_to_cover_letter, PATCH_KIND}, |
| 14 | Cli, | 14 | Cli, |
| 15 | }; | 15 | }; |
| 16 | 16 | ||
| @@ -22,11 +22,7 @@ pub struct SubCommandArgs { | |||
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | #[allow(clippy::too_many_lines)] | 24 | #[allow(clippy::too_many_lines)] |
| 25 | pub async fn launch( | 25 | pub async fn launch(_cli_args: &Cli, _args: &SubCommandArgs) -> Result<()> { |
| 26 | _cli_args: &Cli, | ||
| 27 | _pr_args: &super::SubCommandArgs, | ||
| 28 | _args: &SubCommandArgs, | ||
| 29 | ) -> Result<()> { | ||
| 30 | let git_repo = Repo::discover().context("cannot find a git repository")?; | 26 | let git_repo = Repo::discover().context("cannot find a git repository")?; |
| 31 | 27 | ||
| 32 | let root_commit = git_repo | 28 | let root_commit = git_repo |
diff --git a/src/sub_commands/mod.rs b/src/sub_commands/mod.rs index 8be9004..b16d50f 100644 --- a/src/sub_commands/mod.rs +++ b/src/sub_commands/mod.rs | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | pub mod claim; | 1 | pub mod claim; |
| 2 | pub mod list; | ||
| 2 | pub mod login; | 3 | pub mod login; |
| 3 | pub mod prs; | ||
| 4 | pub mod pull; | 4 | pub mod pull; |
| 5 | pub mod push; | 5 | pub mod push; |
| 6 | pub mod send; | ||
diff --git a/src/sub_commands/prs/mod.rs b/src/sub_commands/prs/mod.rs deleted file mode 100644 index a41c495..0000000 --- a/src/sub_commands/prs/mod.rs +++ /dev/null | |||
| @@ -1,25 +0,0 @@ | |||
| 1 | use anyhow::Result; | ||
| 2 | use clap::Subcommand; | ||
| 3 | |||
| 4 | use crate::Cli; | ||
| 5 | pub mod create; | ||
| 6 | pub mod list; | ||
| 7 | |||
| 8 | #[derive(clap::Parser)] | ||
| 9 | pub struct SubCommandArgs { | ||
| 10 | #[command(subcommand)] | ||
| 11 | pub prs_command: Commands, | ||
| 12 | } | ||
| 13 | |||
| 14 | #[derive(Debug, Subcommand)] | ||
| 15 | pub enum Commands { | ||
| 16 | Create(create::SubCommandArgs), | ||
| 17 | List(list::SubCommandArgs), | ||
| 18 | } | ||
| 19 | |||
| 20 | pub async fn launch(cli_args: &Cli, pr_args: &SubCommandArgs) -> Result<()> { | ||
| 21 | match &pr_args.prs_command { | ||
| 22 | Commands::Create(args) => create::launch(cli_args, pr_args, args).await, | ||
| 23 | Commands::List(args) => list::launch(cli_args, pr_args, args).await, | ||
| 24 | } | ||
| 25 | } | ||
diff --git a/src/sub_commands/pull.rs b/src/sub_commands/pull.rs index 2b20d3d..fc6db37 100644 --- a/src/sub_commands/pull.rs +++ b/src/sub_commands/pull.rs | |||
| @@ -9,7 +9,7 @@ use crate::{ | |||
| 9 | git::{Repo, RepoActions}, | 9 | git::{Repo, RepoActions}, |
| 10 | repo_ref, | 10 | repo_ref, |
| 11 | sub_commands::{ | 11 | sub_commands::{ |
| 12 | prs::list::get_most_recent_patch_with_ancestors, push::fetch_pr_and_most_recent_patch_chain, | 12 | list::get_most_recent_patch_with_ancestors, push::fetch_pr_and_most_recent_patch_chain, |
| 13 | }, | 13 | }, |
| 14 | }; | 14 | }; |
| 15 | 15 | ||
diff --git a/src/sub_commands/push.rs b/src/sub_commands/push.rs index eb42699..cc1f480 100644 --- a/src/sub_commands/push.rs +++ b/src/sub_commands/push.rs | |||
| @@ -10,12 +10,12 @@ use crate::{ | |||
| 10 | git::{str_to_sha1, Repo, RepoActions}, | 10 | git::{str_to_sha1, Repo, RepoActions}, |
| 11 | login, | 11 | login, |
| 12 | repo_ref::{self, RepoRef}, | 12 | repo_ref::{self, RepoRef}, |
| 13 | sub_commands::prs::{ | 13 | sub_commands::{ |
| 14 | create::{event_to_cover_letter, generate_patch_event, send_events}, | ||
| 15 | list::{ | 14 | list::{ |
| 16 | find_commits_for_pr_event, find_pr_events, get_most_recent_patch_with_ancestors, | 15 | find_commits_for_pr_event, find_pr_events, get_most_recent_patch_with_ancestors, |
| 17 | tag_value, | 16 | tag_value, |
| 18 | }, | 17 | }, |
| 18 | send::{event_to_cover_letter, generate_patch_event, send_events}, | ||
| 19 | }, | 19 | }, |
| 20 | Cli, | 20 | Cli, |
| 21 | }; | 21 | }; |
diff --git a/src/sub_commands/prs/create.rs b/src/sub_commands/send.rs index 35e29d3..2c1dec8 100644 --- a/src/sub_commands/prs/create.rs +++ b/src/sub_commands/send.rs | |||
| @@ -39,11 +39,7 @@ pub struct SubCommandArgs { | |||
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | #[allow(clippy::too_many_lines)] | 41 | #[allow(clippy::too_many_lines)] |
| 42 | pub async fn launch( | 42 | pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { |
| 43 | cli_args: &Cli, | ||
| 44 | _pr_args: &super::SubCommandArgs, | ||
| 45 | args: &SubCommandArgs, | ||
| 46 | ) -> Result<()> { | ||
| 47 | let git_repo = Repo::discover().context("cannot find a git repository")?; | 43 | let git_repo = Repo::discover().context("cannot find a git repository")?; |
| 48 | 44 | ||
| 49 | let (from_branch, to_branch, mut ahead, behind) = | 45 | let (from_branch, to_branch, mut ahead, behind) = |
| @@ -178,6 +174,7 @@ pub async fn launch( | |||
| 178 | Ok(()) | 174 | Ok(()) |
| 179 | } | 175 | } |
| 180 | 176 | ||
| 177 | #[allow(clippy::module_name_repetitions)] | ||
| 181 | pub async fn send_events( | 178 | pub async fn send_events( |
| 182 | #[cfg(test)] client: &crate::client::MockConnect, | 179 | #[cfg(test)] client: &crate::client::MockConnect, |
| 183 | #[cfg(not(test))] client: &Client, | 180 | #[cfg(not(test))] client: &Client, |