From 098b0258fdd581c750099cb463adbddb57843388 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 8 Mar 2024 16:49:03 +0000 Subject: feat(send): compare against origin/main vs main catch more errors when proposed commits are not connected to origin/main branch improve default selected commits when on main branch --- src/sub_commands/send.rs | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'src/sub_commands/send.rs') diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs index 9b44cc3..81cecd8 100644 --- a/src/sub_commands/send.rs +++ b/src/sub_commands/send.rs @@ -53,13 +53,13 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { println!("creating proposal revision for: {id}"); } + let (main_branch_name, main_tip) = git_repo + .get_main_or_master_branch() + .context("the default branches (main or master) do not exist")?; + let mut commits: Vec = { if args.since_or_range.is_empty() { let branch_name = git_repo.get_checked_out_branch_name()?; - let (main_branch_name, main_tip) = git_repo - .get_main_or_master_branch() - .context("the default branches (main or master) do not exist")?; - let proposed_commits = if branch_name.eq(main_branch_name) { vec![main_tip] } else { @@ -88,9 +88,6 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { ); } - let (main_branch_name, main_tip) = git_repo - .get_main_or_master_branch() - .context("the default branches (main or master) do not exist")?; let (first_commit_ahead, behind) = git_repo.get_commits_ahead_behind(&main_tip, commits.last().context("no commits")?)?; @@ -385,7 +382,7 @@ fn choose_commits(git_repo: &Repo, proposed_commits: Vec) -> Result ( name.to_string(), git_repo - .get_tip_of_local_branch(name) + .get_tip_of_branch(name) .context(format!("cannot find from_branch '{name}'"))?, ), None => ( @@ -937,7 +942,7 @@ fn identify_ahead_behind( Some(name) => ( name.to_string(), git_repo - .get_tip_of_local_branch(name) + .get_tip_of_branch(name) .context(format!("cannot find to_branch '{name}'"))?, ), None => { -- cgit v1.2.3