diff options
| -rw-r--r-- | src/git.rs | 6 | ||||
| -rw-r--r-- | src/main.rs | 9 | ||||
| -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 | ||||
| -rw-r--r-- | tests/list.rs (renamed from tests/prs_list.rs) | 26 | ||||
| -rw-r--r-- | tests/pull.rs | 3 | ||||
| -rw-r--r-- | tests/push.rs | 3 | ||||
| -rw-r--r-- | tests/send.rs (renamed from tests/prs_create.rs) | 25 |
13 files changed, 43 insertions, 82 deletions
| @@ -6,7 +6,7 @@ use anyhow::{bail, Context, Result}; | |||
| 6 | use git2::{DiffOptions, Oid, Revwalk}; | 6 | use git2::{DiffOptions, Oid, Revwalk}; |
| 7 | use nostr::prelude::{sha1::Hash as Sha1Hash, Hash}; | 7 | use nostr::prelude::{sha1::Hash as Sha1Hash, Hash}; |
| 8 | 8 | ||
| 9 | use crate::sub_commands::prs::list::tag_value; | 9 | use crate::sub_commands::list::tag_value; |
| 10 | 10 | ||
| 11 | pub struct Repo { | 11 | pub struct Repo { |
| 12 | git_repo: git2::Repository, | 12 | git_repo: git2::Repository, |
| @@ -1251,7 +1251,7 @@ mod tests { | |||
| 1251 | mod apply_patch { | 1251 | mod apply_patch { |
| 1252 | 1252 | ||
| 1253 | use super::*; | 1253 | use super::*; |
| 1254 | use crate::{repo_ref::RepoRef, sub_commands::prs::create::generate_patch_event}; | 1254 | use crate::{repo_ref::RepoRef, sub_commands::send::generate_patch_event}; |
| 1255 | 1255 | ||
| 1256 | fn generate_patch_from_head_commit(test_repo: &GitTestRepo) -> Result<nostr::Event> { | 1256 | fn generate_patch_from_head_commit(test_repo: &GitTestRepo) -> Result<nostr::Event> { |
| 1257 | let original_oid = test_repo.git_repo.head()?.peel_to_commit()?.id(); | 1257 | let original_oid = test_repo.git_repo.head()?.peel_to_commit()?.id(); |
| @@ -1405,7 +1405,7 @@ mod tests { | |||
| 1405 | use test_utils::TEST_KEY_1_KEYS; | 1405 | use test_utils::TEST_KEY_1_KEYS; |
| 1406 | 1406 | ||
| 1407 | use super::*; | 1407 | use super::*; |
| 1408 | use crate::{repo_ref::RepoRef, sub_commands::prs::create::generate_pr_and_patch_events}; | 1408 | use crate::{repo_ref::RepoRef, sub_commands::send::generate_pr_and_patch_events}; |
| 1409 | 1409 | ||
| 1410 | static BRANCH_NAME: &str = "add-example-feature"; | 1410 | static BRANCH_NAME: &str = "add-example-feature"; |
| 1411 | // returns original_repo, pr_event, patch_events | 1411 | // returns original_repo, pr_event, patch_events |
diff --git a/src/main.rs b/src/main.rs index 85b2812..539d9ff 100644 --- a/src/main.rs +++ b/src/main.rs | |||
| @@ -36,8 +36,10 @@ enum Commands { | |||
| 36 | Login(sub_commands::login::SubCommandArgs), | 36 | Login(sub_commands::login::SubCommandArgs), |
| 37 | /// issue repository reference event as a maintainers | 37 | /// issue repository reference event as a maintainers |
| 38 | Claim(sub_commands::claim::SubCommandArgs), | 38 | Claim(sub_commands::claim::SubCommandArgs), |
| 39 | /// create and issue prs | 39 | /// send a PR / patch / patch set via nostr events |
| 40 | Prs(sub_commands::prs::SubCommandArgs), | 40 | Send(sub_commands::send::SubCommandArgs), |
| 41 | /// list open PRs / patches / patch sets and pull / apply them a branch | ||
| 42 | List(sub_commands::list::SubCommandArgs), | ||
| 41 | /// pull latest commits in pr linked to checked out branch | 43 | /// pull latest commits in pr linked to checked out branch |
| 42 | Pull, | 44 | Pull, |
| 43 | /// push commits to current checked out pr branch | 45 | /// push commits to current checked out pr branch |
| @@ -50,7 +52,8 @@ async fn main() -> Result<()> { | |||
| 50 | match &cli.command { | 52 | match &cli.command { |
| 51 | Commands::Login(args) => sub_commands::login::launch(&cli, args).await, | 53 | Commands::Login(args) => sub_commands::login::launch(&cli, args).await, |
| 52 | Commands::Claim(args) => sub_commands::claim::launch(&cli, args).await, | 54 | Commands::Claim(args) => sub_commands::claim::launch(&cli, args).await, |
| 53 | Commands::Prs(args) => sub_commands::prs::launch(&cli, args).await, | 55 | Commands::Send(args) => sub_commands::send::launch(&cli, args).await, |
| 56 | Commands::List(args) => sub_commands::list::launch(&cli, args).await, | ||
| 54 | Commands::Pull => sub_commands::pull::launch().await, | 57 | Commands::Pull => sub_commands::pull::launch().await, |
| 55 | Commands::Push => sub_commands::push::launch(&cli).await, | 58 | Commands::Push => sub_commands::push::launch(&cli).await, |
| 56 | } | 59 | } |
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, |
diff --git a/tests/prs_list.rs b/tests/list.rs index 7c0d8ec..0d1d4e9 100644 --- a/tests/prs_list.rs +++ b/tests/list.rs | |||
| @@ -77,8 +77,7 @@ fn cli_tester_create_pr( | |||
| 77 | "--password", | 77 | "--password", |
| 78 | TEST_PASSWORD, | 78 | TEST_PASSWORD, |
| 79 | "--disable-cli-spinners", | 79 | "--disable-cli-spinners", |
| 80 | "prs", | 80 | "send", |
| 81 | "create", | ||
| 82 | "--title", | 81 | "--title", |
| 83 | format!("\"{title}\"").as_str(), | 82 | format!("\"{title}\"").as_str(), |
| 84 | "--description", | 83 | "--description", |
| @@ -95,8 +94,7 @@ fn cli_tester_create_pr( | |||
| 95 | "--password", | 94 | "--password", |
| 96 | TEST_PASSWORD, | 95 | TEST_PASSWORD, |
| 97 | "--disable-cli-spinners", | 96 | "--disable-cli-spinners", |
| 98 | "prs", | 97 | "send", |
| 99 | "create", | ||
| 100 | "--no-cover-letter", | 98 | "--no-cover-letter", |
| 101 | ], | 99 | ], |
| 102 | ); | 100 | ); |
| @@ -143,7 +141,7 @@ mod when_main_branch_is_uptodate { | |||
| 143 | 141 | ||
| 144 | let test_repo = GitTestRepo::default(); | 142 | let test_repo = GitTestRepo::default(); |
| 145 | test_repo.populate()?; | 143 | test_repo.populate()?; |
| 146 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["prs", "list"]); | 144 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 147 | 145 | ||
| 148 | p.expect("finding PRs...\r\n")?; | 146 | p.expect("finding PRs...\r\n")?; |
| 149 | let mut c = p.expect_choice( | 147 | let mut c = p.expect_choice( |
| @@ -203,7 +201,7 @@ mod when_main_branch_is_uptodate { | |||
| 203 | 201 | ||
| 204 | let test_repo = GitTestRepo::default(); | 202 | let test_repo = GitTestRepo::default(); |
| 205 | test_repo.populate()?; | 203 | test_repo.populate()?; |
| 206 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["prs", "list"]); | 204 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 207 | 205 | ||
| 208 | p.expect("finding PRs...\r\n")?; | 206 | p.expect("finding PRs...\r\n")?; |
| 209 | let mut c = p.expect_choice( | 207 | let mut c = p.expect_choice( |
| @@ -308,7 +306,7 @@ mod when_main_branch_is_uptodate { | |||
| 308 | 306 | ||
| 309 | let test_repo = GitTestRepo::default(); | 307 | let test_repo = GitTestRepo::default(); |
| 310 | test_repo.populate()?; | 308 | test_repo.populate()?; |
| 311 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["prs", "list"]); | 309 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 312 | 310 | ||
| 313 | p.expect("finding PRs...\r\n")?; | 311 | p.expect("finding PRs...\r\n")?; |
| 314 | let mut c = p.expect_choice( | 312 | let mut c = p.expect_choice( |
| @@ -368,7 +366,7 @@ mod when_main_branch_is_uptodate { | |||
| 368 | 366 | ||
| 369 | let test_repo = GitTestRepo::default(); | 367 | let test_repo = GitTestRepo::default(); |
| 370 | test_repo.populate()?; | 368 | test_repo.populate()?; |
| 371 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["prs", "list"]); | 369 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 372 | 370 | ||
| 373 | p.expect("finding PRs...\r\n")?; | 371 | p.expect("finding PRs...\r\n")?; |
| 374 | let mut c = p.expect_choice( | 372 | let mut c = p.expect_choice( |
| @@ -478,7 +476,7 @@ mod when_main_branch_is_uptodate { | |||
| 478 | )?; | 476 | )?; |
| 479 | let test_repo = GitTestRepo::default(); | 477 | let test_repo = GitTestRepo::default(); |
| 480 | test_repo.populate()?; | 478 | test_repo.populate()?; |
| 481 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["prs", "list"]); | 479 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 482 | 480 | ||
| 483 | p.expect("finding PRs...\r\n")?; | 481 | p.expect("finding PRs...\r\n")?; |
| 484 | let mut c = p.expect_choice( | 482 | let mut c = p.expect_choice( |
| @@ -544,7 +542,7 @@ mod when_main_branch_is_uptodate { | |||
| 544 | )?; | 542 | )?; |
| 545 | let test_repo = GitTestRepo::default(); | 543 | let test_repo = GitTestRepo::default(); |
| 546 | test_repo.populate()?; | 544 | test_repo.populate()?; |
| 547 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["prs", "list"]); | 545 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 548 | 546 | ||
| 549 | p.expect("finding PRs...\r\n")?; | 547 | p.expect("finding PRs...\r\n")?; |
| 550 | let mut c = p.expect_choice( | 548 | let mut c = p.expect_choice( |
| @@ -658,7 +656,7 @@ mod when_main_branch_is_uptodate { | |||
| 658 | 656 | ||
| 659 | let test_repo = GitTestRepo::default(); | 657 | let test_repo = GitTestRepo::default(); |
| 660 | test_repo.populate()?; | 658 | test_repo.populate()?; |
| 661 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["prs", "list"]); | 659 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 662 | 660 | ||
| 663 | create_and_populate_branch( | 661 | create_and_populate_branch( |
| 664 | &test_repo, | 662 | &test_repo, |
| @@ -725,7 +723,7 @@ mod when_main_branch_is_uptodate { | |||
| 725 | 723 | ||
| 726 | let test_repo = GitTestRepo::default(); | 724 | let test_repo = GitTestRepo::default(); |
| 727 | test_repo.populate()?; | 725 | test_repo.populate()?; |
| 728 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["prs", "list"]); | 726 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 729 | 727 | ||
| 730 | create_and_populate_branch( | 728 | create_and_populate_branch( |
| 731 | &test_repo, | 729 | &test_repo, |
| @@ -817,7 +815,7 @@ mod when_main_branch_is_uptodate { | |||
| 817 | 815 | ||
| 818 | let test_repo = GitTestRepo::default(); | 816 | let test_repo = GitTestRepo::default(); |
| 819 | test_repo.populate()?; | 817 | test_repo.populate()?; |
| 820 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["prs", "list"]); | 818 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 821 | 819 | ||
| 822 | create_and_populate_branch( | 820 | create_and_populate_branch( |
| 823 | &test_repo, | 821 | &test_repo, |
| @@ -885,7 +883,7 @@ mod when_main_branch_is_uptodate { | |||
| 885 | 883 | ||
| 886 | let test_repo = GitTestRepo::default(); | 884 | let test_repo = GitTestRepo::default(); |
| 887 | test_repo.populate()?; | 885 | test_repo.populate()?; |
| 888 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["prs", "list"]); | 886 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 889 | 887 | ||
| 890 | create_and_populate_branch( | 888 | create_and_populate_branch( |
| 891 | &test_repo, | 889 | &test_repo, |
diff --git a/tests/pull.rs b/tests/pull.rs index 92d0ba9..d3064a3 100644 --- a/tests/pull.rs +++ b/tests/pull.rs | |||
| @@ -79,8 +79,7 @@ fn cli_tester_create_pr( | |||
| 79 | "--password", | 79 | "--password", |
| 80 | TEST_PASSWORD, | 80 | TEST_PASSWORD, |
| 81 | "--disable-cli-spinners", | 81 | "--disable-cli-spinners", |
| 82 | "prs", | 82 | "send", |
| 83 | "create", | ||
| 84 | "--title", | 83 | "--title", |
| 85 | format!("\"{title}\"").as_str(), | 84 | format!("\"{title}\"").as_str(), |
| 86 | "--description", | 85 | "--description", |
diff --git a/tests/push.rs b/tests/push.rs index 4af5bd4..9791d9d 100644 --- a/tests/push.rs +++ b/tests/push.rs | |||
| @@ -79,8 +79,7 @@ fn cli_tester_create_pr( | |||
| 79 | "--password", | 79 | "--password", |
| 80 | TEST_PASSWORD, | 80 | TEST_PASSWORD, |
| 81 | "--disable-cli-spinners", | 81 | "--disable-cli-spinners", |
| 82 | "prs", | 82 | "send", |
| 83 | "create", | ||
| 84 | "--title", | 83 | "--title", |
| 85 | format!("\"{title}\"").as_str(), | 84 | format!("\"{title}\"").as_str(), |
| 86 | "--description", | 85 | "--description", |
diff --git a/tests/prs_create.rs b/tests/send.rs index 5d55ab9..a109918 100644 --- a/tests/prs_create.rs +++ b/tests/send.rs | |||
| @@ -7,10 +7,7 @@ use test_utils::{git::GitTestRepo, relay::Relay, *}; | |||
| 7 | fn when_to_branch_doesnt_exist_return_error() -> Result<()> { | 7 | fn when_to_branch_doesnt_exist_return_error() -> Result<()> { |
| 8 | let test_repo = GitTestRepo::default(); | 8 | let test_repo = GitTestRepo::default(); |
| 9 | test_repo.populate()?; | 9 | test_repo.populate()?; |
| 10 | let mut p = CliTester::new_from_dir( | 10 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["send", "--to-branch", "nonexistant"]); |
| 11 | &test_repo.dir, | ||
| 12 | ["prs", "create", "--to-branch", "nonexistant"], | ||
| 13 | ); | ||
| 14 | p.expect("Error: cannot find to_branch 'nonexistant'")?; | 11 | p.expect("Error: cannot find to_branch 'nonexistant'")?; |
| 15 | Ok(()) | 12 | Ok(()) |
| 16 | } | 13 | } |
| @@ -19,7 +16,7 @@ fn when_to_branch_doesnt_exist_return_error() -> Result<()> { | |||
| 19 | fn when_no_to_branch_specified_and_no_main_or_master_branch_return_error() -> Result<()> { | 16 | fn when_no_to_branch_specified_and_no_main_or_master_branch_return_error() -> Result<()> { |
| 20 | let test_repo = GitTestRepo::new("notmain")?; | 17 | let test_repo = GitTestRepo::new("notmain")?; |
| 21 | test_repo.populate()?; | 18 | test_repo.populate()?; |
| 22 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["prs", "create"]); | 19 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["send"]); |
| 23 | p.expect("Error: a destination branch (to_branch) is not specified and the defaults (main or master) do not exist")?; | 20 | p.expect("Error: a destination branch (to_branch) is not specified and the defaults (main or master) do not exist")?; |
| 24 | Ok(()) | 21 | Ok(()) |
| 25 | } | 22 | } |
| @@ -28,10 +25,7 @@ fn when_no_to_branch_specified_and_no_main_or_master_branch_return_error() -> Re | |||
| 28 | fn when_from_branch_doesnt_exist_return_error() -> Result<()> { | 25 | fn when_from_branch_doesnt_exist_return_error() -> Result<()> { |
| 29 | let test_repo = GitTestRepo::default(); | 26 | let test_repo = GitTestRepo::default(); |
| 30 | test_repo.populate()?; | 27 | test_repo.populate()?; |
| 31 | let mut p = CliTester::new_from_dir( | 28 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["send", "--from-branch", "nonexistant"]); |
| 32 | &test_repo.dir, | ||
| 33 | ["prs", "create", "--from-branch", "nonexistant"], | ||
| 34 | ); | ||
| 35 | p.expect("Error: cannot find from_branch 'nonexistant'")?; | 29 | p.expect("Error: cannot find from_branch 'nonexistant'")?; |
| 36 | Ok(()) | 30 | Ok(()) |
| 37 | } | 31 | } |
| @@ -44,7 +38,7 @@ fn when_no_commits_ahead_of_main_return_error() -> Result<()> { | |||
| 44 | test_repo.create_branch("feature")?; | 38 | test_repo.create_branch("feature")?; |
| 45 | test_repo.checkout("feature")?; | 39 | test_repo.checkout("feature")?; |
| 46 | 40 | ||
| 47 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["prs", "create"]); | 41 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["send"]); |
| 48 | p.expect("Error: 'head' is 0 commits ahead of 'main' so no patches were created")?; | 42 | p.expect("Error: 'head' is 0 commits ahead of 'main' so no patches were created")?; |
| 49 | Ok(()) | 43 | Ok(()) |
| 50 | } | 44 | } |
| @@ -88,7 +82,7 @@ mod when_commits_behind_ask_to_proceed { | |||
| 88 | fn asked_with_default_no() -> Result<()> { | 82 | fn asked_with_default_no() -> Result<()> { |
| 89 | let test_repo = prep_test_repo()?; | 83 | let test_repo = prep_test_repo()?; |
| 90 | 84 | ||
| 91 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["prs", "create"]); | 85 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["send"]); |
| 92 | expect_confirm_prompt(&mut p, BEHIND_LEN, AHEAD_LEN)?; | 86 | expect_confirm_prompt(&mut p, BEHIND_LEN, AHEAD_LEN)?; |
| 93 | p.exit()?; | 87 | p.exit()?; |
| 94 | Ok(()) | 88 | Ok(()) |
| @@ -98,7 +92,7 @@ mod when_commits_behind_ask_to_proceed { | |||
| 98 | fn when_response_is_false_aborts() -> Result<()> { | 92 | fn when_response_is_false_aborts() -> Result<()> { |
| 99 | let test_repo = prep_test_repo()?; | 93 | let test_repo = prep_test_repo()?; |
| 100 | 94 | ||
| 101 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["prs", "create"]); | 95 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["send"]); |
| 102 | 96 | ||
| 103 | expect_confirm_prompt(&mut p, BEHIND_LEN, AHEAD_LEN)?.succeeds_with(Some(false))?; | 97 | expect_confirm_prompt(&mut p, BEHIND_LEN, AHEAD_LEN)?.succeeds_with(Some(false))?; |
| 104 | 98 | ||
| @@ -111,7 +105,7 @@ mod when_commits_behind_ask_to_proceed { | |||
| 111 | fn when_response_is_true_proceeds() -> Result<()> { | 105 | fn when_response_is_true_proceeds() -> Result<()> { |
| 112 | let test_repo = prep_test_repo()?; | 106 | let test_repo = prep_test_repo()?; |
| 113 | 107 | ||
| 114 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["prs", "create"]); | 108 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["send"]); |
| 115 | expect_confirm_prompt(&mut p, BEHIND_LEN, AHEAD_LEN)?.succeeds_with(Some(true))?; | 109 | expect_confirm_prompt(&mut p, BEHIND_LEN, AHEAD_LEN)?.succeeds_with(Some(true))?; |
| 116 | p.expect( | 110 | p.expect( |
| 117 | format!("creating patch for {AHEAD_LEN} commits from 'head' that are {BEHIND_LEN} behind 'main'",) | 111 | format!("creating patch for {AHEAD_LEN} commits from 'head' that are {BEHIND_LEN} behind 'main'",) |
| @@ -135,7 +129,7 @@ fn cli_message_creating_patches() -> Result<()> { | |||
| 135 | std::fs::write(test_repo.dir.join("t4.md"), "some content")?; | 129 | std::fs::write(test_repo.dir.join("t4.md"), "some content")?; |
| 136 | test_repo.stage_and_commit("add t4.md")?; | 130 | test_repo.stage_and_commit("add t4.md")?; |
| 137 | 131 | ||
| 138 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["prs", "create"]); | 132 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["send"]); |
| 139 | 133 | ||
| 140 | p.expect("creating patch for 2 commits from 'head' that can be merged into 'main'")?; | 134 | p.expect("creating patch for 2 commits from 'head' that can be merged into 'main'")?; |
| 141 | p.exit()?; | 135 | p.exit()?; |
| @@ -172,8 +166,7 @@ fn cli_tester_create_pr(git_repo: &GitTestRepo, include_cover_letter: bool) -> C | |||
| 172 | "--password", | 166 | "--password", |
| 173 | TEST_PASSWORD, | 167 | TEST_PASSWORD, |
| 174 | "--disable-cli-spinners", | 168 | "--disable-cli-spinners", |
| 175 | "prs", | 169 | "send", |
| 176 | "create", | ||
| 177 | ]; | 170 | ]; |
| 178 | if include_cover_letter { | 171 | if include_cover_letter { |
| 179 | for arg in [ | 172 | for arg in [ |