diff options
| -rw-r--r-- | src/sub_commands/send.rs | 8 | ||||
| -rw-r--r-- | tests/send.rs | 22 |
2 files changed, 7 insertions, 23 deletions
diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs index 588e7d1..b5ab78f 100644 --- a/src/sub_commands/send.rs +++ b/src/sub_commands/send.rs | |||
| @@ -47,7 +47,9 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 47 | let git_repo = Repo::discover().context("cannot find a git repository")?; | 47 | let git_repo = Repo::discover().context("cannot find a git repository")?; |
| 48 | 48 | ||
| 49 | let mut commits: Vec<Sha1Hash> = { | 49 | let mut commits: Vec<Sha1Hash> = { |
| 50 | if args.since_or_revision_range.eq("master..HEAD") { | 50 | if args.since_or_revision_range.is_empty() |
| 51 | || args.since_or_revision_range.eq("master..HEAD") | ||
| 52 | { | ||
| 51 | let (from_branch, to_branch, ahead, behind) = | 53 | let (from_branch, to_branch, ahead, behind) = |
| 52 | identify_ahead_behind(&git_repo, &None, &None)?; | 54 | identify_ahead_behind(&git_repo, &None, &None)?; |
| 53 | 55 | ||
| @@ -794,7 +796,7 @@ fn identify_ahead_behind( | |||
| 794 | None => { | 796 | None => { |
| 795 | let (name, commit) = git_repo | 797 | let (name, commit) = git_repo |
| 796 | .get_main_or_master_branch() | 798 | .get_main_or_master_branch() |
| 797 | .context("a destination branch (to_branch) is not specified and the defaults (main or master) do not exist")?; | 799 | .context("the default branches (main or master) do not exist")?; |
| 798 | (name.to_string(), commit) | 800 | (name.to_string(), commit) |
| 799 | } | 801 | } |
| 800 | }; | 802 | }; |
| @@ -867,7 +869,7 @@ mod tests { | |||
| 867 | identify_ahead_behind(&git_repo, &None, &None) | 869 | identify_ahead_behind(&git_repo, &None, &None) |
| 868 | .unwrap_err() | 870 | .unwrap_err() |
| 869 | .to_string(), | 871 | .to_string(), |
| 870 | "a destination branch (to_branch) is not specified and the defaults (main or master) do not exist", | 872 | "the default branches (main or master) do not exist", |
| 871 | ); | 873 | ); |
| 872 | Ok(()) | 874 | Ok(()) |
| 873 | } | 875 | } |
diff --git a/tests/send.rs b/tests/send.rs index 58c21f9..06f1b86 100644 --- a/tests/send.rs +++ b/tests/send.rs | |||
| @@ -4,29 +4,11 @@ use serial_test::serial; | |||
| 4 | use test_utils::{git::GitTestRepo, relay::Relay, *}; | 4 | use test_utils::{git::GitTestRepo, relay::Relay, *}; |
| 5 | 5 | ||
| 6 | #[test] | 6 | #[test] |
| 7 | fn when_to_branch_doesnt_exist_return_error() -> Result<()> { | 7 | fn when_no_main_or_master_branch_return_error() -> Result<()> { |
| 8 | let test_repo = GitTestRepo::default(); | ||
| 9 | test_repo.populate()?; | ||
| 10 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["send", "--to-branch", "nonexistant"]); | ||
| 11 | p.expect("Error: cannot find to_branch 'nonexistant'")?; | ||
| 12 | Ok(()) | ||
| 13 | } | ||
| 14 | |||
| 15 | #[test] | ||
| 16 | fn when_no_to_branch_specified_and_no_main_or_master_branch_return_error() -> Result<()> { | ||
| 17 | let test_repo = GitTestRepo::new("notmain")?; | 8 | let test_repo = GitTestRepo::new("notmain")?; |
| 18 | test_repo.populate()?; | 9 | test_repo.populate()?; |
| 19 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["send"]); | 10 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["send"]); |
| 20 | p.expect("Error: a destination branch (to_branch) is not specified and the defaults (main or master) do not exist")?; | 11 | p.expect("Error: the default branches (main or master) do not exist")?; |
| 21 | Ok(()) | ||
| 22 | } | ||
| 23 | |||
| 24 | #[test] | ||
| 25 | fn when_from_branch_doesnt_exist_return_error() -> Result<()> { | ||
| 26 | let test_repo = GitTestRepo::default(); | ||
| 27 | test_repo.populate()?; | ||
| 28 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["send", "--from-branch", "nonexistant"]); | ||
| 29 | p.expect("Error: cannot find from_branch 'nonexistant'")?; | ||
| 30 | Ok(()) | 12 | Ok(()) |
| 31 | } | 13 | } |
| 32 | 14 | ||