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/list.rs | 2 +- src/sub_commands/pull.rs | 2 +- src/sub_commands/push.rs | 2 +- src/sub_commands/send.rs | 29 +++++++++++++++++------------ 4 files changed, 20 insertions(+), 15 deletions(-) (limited to 'src/sub_commands') diff --git a/src/sub_commands/list.rs b/src/sub_commands/list.rs index ad5a28d..102c3bd 100644 --- a/src/sub_commands/list.rs +++ b/src/sub_commands/list.rs @@ -274,7 +274,7 @@ pub async fn launch(_cli_args: &Cli, _args: &SubCommandArgs) -> Result<()> { }; } - let local_branch_tip = git_repo.get_tip_of_local_branch(&cover_letter.branch_name)?; + let local_branch_tip = git_repo.get_tip_of_branch(&cover_letter.branch_name)?; // up-to-date if proposal_tip.eq(&local_branch_tip) { diff --git a/src/sub_commands/pull.rs b/src/sub_commands/pull.rs index daae37f..716e6c5 100644 --- a/src/sub_commands/pull.rs +++ b/src/sub_commands/pull.rs @@ -60,7 +60,7 @@ pub async fn launch() -> Result<()> { get_most_recent_patch_with_ancestors(commit_events.clone()) .context("cannot get most recent patch for proposal")?; - let local_branch_tip = git_repo.get_tip_of_local_branch(&branch_name)?; + let local_branch_tip = git_repo.get_tip_of_branch(&branch_name)?; let (main_branch_name, master_tip) = git_repo.get_main_or_master_branch()?; diff --git a/src/sub_commands/push.rs b/src/sub_commands/push.rs index fdaab8e..651b250 100644 --- a/src/sub_commands/push.rs +++ b/src/sub_commands/push.rs @@ -75,7 +75,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { let most_recent_proposal_patch_chain = get_most_recent_patch_with_ancestors(commit_events) .context("cannot get most recent patch for proposal")?; - let branch_tip = git_repo.get_tip_of_local_branch(&branch_name)?; + let branch_tip = git_repo.get_tip_of_branch(&branch_name)?; let most_recent_patch_commit_id = str_to_sha1( &get_commit_id_from_patch( 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