upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/sub_commands/send.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-03-08 16:49:03 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2024-03-08 17:27:13 +0000
commit098b0258fdd581c750099cb463adbddb57843388 (patch)
tree000b80fd630083aefef314ec999060c65fb57573 /src/sub_commands/send.rs
parent6b3aecbcbde669859533716225e9c3bbfd2023b2 (diff)
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
Diffstat (limited to 'src/sub_commands/send.rs')
-rw-r--r--src/sub_commands/send.rs29
1 files changed, 17 insertions, 12 deletions
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<()> {
53 println!("creating proposal revision for: {id}"); 53 println!("creating proposal revision for: {id}");
54 } 54 }
55 55
56 let (main_branch_name, main_tip) = git_repo
57 .get_main_or_master_branch()
58 .context("the default branches (main or master) do not exist")?;
59
56 let mut commits: Vec<Sha1Hash> = { 60 let mut commits: Vec<Sha1Hash> = {
57 if args.since_or_range.is_empty() { 61 if args.since_or_range.is_empty() {
58 let branch_name = git_repo.get_checked_out_branch_name()?; 62 let branch_name = git_repo.get_checked_out_branch_name()?;
59 let (main_branch_name, main_tip) = git_repo
60 .get_main_or_master_branch()
61 .context("the default branches (main or master) do not exist")?;
62
63 let proposed_commits = if branch_name.eq(main_branch_name) { 63 let proposed_commits = if branch_name.eq(main_branch_name) {
64 vec![main_tip] 64 vec![main_tip]
65 } else { 65 } else {
@@ -88,9 +88,6 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
88 ); 88 );
89 } 89 }
90 90
91 let (main_branch_name, main_tip) = git_repo
92 .get_main_or_master_branch()
93 .context("the default branches (main or master) do not exist")?;
94 let (first_commit_ahead, behind) = 91 let (first_commit_ahead, behind) =
95 git_repo.get_commits_ahead_behind(&main_tip, commits.last().context("no commits")?)?; 92 git_repo.get_commits_ahead_behind(&main_tip, commits.last().context("no commits")?)?;
96 93
@@ -385,7 +382,7 @@ fn choose_commits(git_repo: &Repo, proposed_commits: Vec<Sha1Hash>) -> Result<Ve
385 proposed_commits 382 proposed_commits
386 }; 383 };
387 384
388 let tip_of_head = git_repo.get_tip_of_local_branch(&git_repo.get_checked_out_branch_name()?)?; 385 let tip_of_head = git_repo.get_tip_of_branch(&git_repo.get_checked_out_branch_name()?)?;
389 let most_recent_commit = proposed_commits.first().unwrap_or(&tip_of_head); 386 let most_recent_commit = proposed_commits.first().unwrap_or(&tip_of_head);
390 387
391 let mut last_15_commits = vec![*most_recent_commit]; 388 let mut last_15_commits = vec![*most_recent_commit];
@@ -571,7 +568,11 @@ pub fn generate_cover_letter_and_patch_events(
571 // a change like this, or the removal of this tag will require the actual branch name to be tracked 568 // a change like this, or the removal of this tag will require the actual branch name to be tracked
572 // so pulling and pushing still work 569 // so pulling and pushing still work
573 if let Ok(branch_name) = git_repo.get_checked_out_branch_name() { 570 if let Ok(branch_name) = git_repo.get_checked_out_branch_name() {
574 if !branch_name.eq("main") && !branch_name.eq("master") { 571 if !branch_name.eq("main")
572 && !branch_name.eq("master")
573 && !branch_name.eq("origin/main")
574 && !branch_name.eq("origin/master")
575 {
575 vec![Tag::Generic( 576 vec![Tag::Generic(
576 TagKind::Custom("branch-name".to_string()), 577 TagKind::Custom("branch-name".to_string()),
577 vec![branch_name], 578 vec![branch_name],
@@ -608,7 +609,11 @@ pub fn generate_cover_letter_and_patch_events(
608 }, 609 },
609 if events.is_empty() { 610 if events.is_empty() {
610 if let Ok(branch_name) = git_repo.get_checked_out_branch_name() { 611 if let Ok(branch_name) = git_repo.get_checked_out_branch_name() {
611 if !branch_name.eq("main") && !branch_name.eq("master") { 612 if !branch_name.eq("main")
613 && !branch_name.eq("master")
614 && !branch_name.eq("origin/main")
615 && !branch_name.eq("origin/master")
616 {
612 Some(branch_name) 617 Some(branch_name)
613 } else { 618 } else {
614 None 619 None
@@ -915,7 +920,7 @@ fn identify_ahead_behind(
915 Some(name) => ( 920 Some(name) => (
916 name.to_string(), 921 name.to_string(),
917 git_repo 922 git_repo
918 .get_tip_of_local_branch(name) 923 .get_tip_of_branch(name)
919 .context(format!("cannot find from_branch '{name}'"))?, 924 .context(format!("cannot find from_branch '{name}'"))?,
920 ), 925 ),
921 None => ( 926 None => (
@@ -937,7 +942,7 @@ fn identify_ahead_behind(
937 Some(name) => ( 942 Some(name) => (
938 name.to_string(), 943 name.to_string(),
939 git_repo 944 git_repo
940 .get_tip_of_local_branch(name) 945 .get_tip_of_branch(name)
941 .context(format!("cannot find to_branch '{name}'"))?, 946 .context(format!("cannot find to_branch '{name}'"))?,
942 ), 947 ),
943 None => { 948 None => {