From a9e4c6772a378fd28edbca9b9267d2e7d08bee2c Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 23 Feb 2024 12:25:11 +0000 Subject: fix(push): remove force push bug introduced in b931b37e26486e4e6d15f302e87141dcf2f596ba --- src/sub_commands/send.rs | 8 +++++--- 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<()> { let git_repo = Repo::discover().context("cannot find a git repository")?; let mut commits: Vec = { - if args.since_or_revision_range.eq("master..HEAD") { + if args.since_or_revision_range.is_empty() + || args.since_or_revision_range.eq("master..HEAD") + { let (from_branch, to_branch, ahead, behind) = identify_ahead_behind(&git_repo, &None, &None)?; @@ -794,7 +796,7 @@ fn identify_ahead_behind( None => { let (name, commit) = git_repo .get_main_or_master_branch() - .context("a destination branch (to_branch) is not specified and the defaults (main or master) do not exist")?; + .context("the default branches (main or master) do not exist")?; (name.to_string(), commit) } }; @@ -867,7 +869,7 @@ mod tests { identify_ahead_behind(&git_repo, &None, &None) .unwrap_err() .to_string(), - "a destination branch (to_branch) is not specified and the defaults (main or master) do not exist", + "the default branches (main or master) do not exist", ); Ok(()) } 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; use test_utils::{git::GitTestRepo, relay::Relay, *}; #[test] -fn when_to_branch_doesnt_exist_return_error() -> Result<()> { - let test_repo = GitTestRepo::default(); - test_repo.populate()?; - let mut p = CliTester::new_from_dir(&test_repo.dir, ["send", "--to-branch", "nonexistant"]); - p.expect("Error: cannot find to_branch 'nonexistant'")?; - Ok(()) -} - -#[test] -fn when_no_to_branch_specified_and_no_main_or_master_branch_return_error() -> Result<()> { +fn when_no_main_or_master_branch_return_error() -> Result<()> { let test_repo = GitTestRepo::new("notmain")?; test_repo.populate()?; let mut p = CliTester::new_from_dir(&test_repo.dir, ["send"]); - p.expect("Error: a destination branch (to_branch) is not specified and the defaults (main or master) do not exist")?; - Ok(()) -} - -#[test] -fn when_from_branch_doesnt_exist_return_error() -> Result<()> { - let test_repo = GitTestRepo::default(); - test_repo.populate()?; - let mut p = CliTester::new_from_dir(&test_repo.dir, ["send", "--from-branch", "nonexistant"]); - p.expect("Error: cannot find from_branch 'nonexistant'")?; + p.expect("Error: the default branches (main or master) do not exist")?; Ok(()) } -- cgit v1.2.3