upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-02-23 12:25:11 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2024-02-23 12:25:11 +0000
commita9e4c6772a378fd28edbca9b9267d2e7d08bee2c (patch)
tree2362ef64da099c87c75e6dde3b0425b2aa0d190c
parent991da4d8dc2bbdd9832dd9252ebebc27d612154c (diff)
fix(push): remove force push bug
introduced in b931b37e26486e4e6d15f302e87141dcf2f596ba
-rw-r--r--src/sub_commands/send.rs8
-rw-r--r--tests/send.rs22
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;
4use test_utils::{git::GitTestRepo, relay::Relay, *}; 4use test_utils::{git::GitTestRepo, relay::Relay, *};
5 5
6#[test] 6#[test]
7fn when_to_branch_doesnt_exist_return_error() -> Result<()> { 7fn 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]
16fn 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]
25fn 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