From b67376ff54abeab31422921ba5f4883d5d3dccdb Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Tue, 23 Jul 2024 16:36:06 +0100 Subject: feat(list): unique proposal branch names to prevent accidental name conflicts. also moved to prs/* namespace `pull` and `push` integration tests are intermitantly failing to end at least for `push` they work when run individually but not when run together --- src/sub_commands/list.rs | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'src/sub_commands/list.rs') diff --git a/src/sub_commands/list.rs b/src/sub_commands/list.rs index 2ae4cfb..cc7ac6f 100644 --- a/src/sub_commands/list.rs +++ b/src/sub_commands/list.rs @@ -263,11 +263,11 @@ pub async fn launch() -> Result<()> { .get_local_branch_names() .context("gitlib2 will not show a list of local branch names")? .iter() - .any(|n| n.eq(&cover_letter.branch_name)); + .any(|n| n.eq(&cover_letter.get_branch_name().unwrap())); let checked_out_proposal_branch = git_repo .get_checked_out_branch_name()? - .eq(&cover_letter.branch_name); + .eq(&cover_letter.get_branch_name()?); let proposal_base_commit = str_to_sha1(&tag_value( most_recent_proposal_patch_chain.last().context( @@ -329,14 +329,14 @@ pub async fn launch() -> Result<()> { check_clean(&git_repo)?; let _ = git_repo .apply_patch_chain( - &cover_letter.branch_name, + &cover_letter.get_branch_name()?, most_recent_proposal_patch_chain, ) .context("cannot apply patch chain")?; println!( "checked out proposal as '{}' branch", - cover_letter.branch_name + cover_letter.get_branch_name()? ); Ok(()) } @@ -349,7 +349,7 @@ pub async fn launch() -> Result<()> { }; } - let local_branch_tip = git_repo.get_tip_of_branch(&cover_letter.branch_name)?; + let local_branch_tip = git_repo.get_tip_of_branch(&cover_letter.get_branch_name()?)?; // up-to-date if proposal_tip.eq(&local_branch_tip) { @@ -384,10 +384,10 @@ pub async fn launch() -> Result<()> { )? { 0 => { check_clean(&git_repo)?; - git_repo.checkout(&cover_letter.branch_name)?; + git_repo.checkout(&cover_letter.get_branch_name()?)?; println!( "checked out proposal as '{}' branch", - cover_letter.branch_name + cover_letter.get_branch_name()? ); Ok(()) } @@ -421,10 +421,10 @@ pub async fn launch() -> Result<()> { )? { 0 => { check_clean(&git_repo)?; - git_repo.checkout(&cover_letter.branch_name)?; + git_repo.checkout(&cover_letter.get_branch_name()?)?; let _ = git_repo .apply_patch_chain( - &cover_letter.branch_name, + &cover_letter.get_branch_name()?, most_recent_proposal_patch_chain, ) .context("cannot apply patch chain")?; @@ -474,14 +474,14 @@ pub async fn launch() -> Result<()> { 0 => { check_clean(&git_repo)?; git_repo.create_branch_at_commit( - &cover_letter.branch_name, + &cover_letter.get_branch_name()?, &proposal_base_commit.to_string(), )?; - git_repo.checkout(&cover_letter.branch_name)?; + git_repo.checkout(&cover_letter.get_branch_name()?)?; let chain_length = most_recent_proposal_patch_chain.len(); let _ = git_repo .apply_patch_chain( - &cover_letter.branch_name, + &cover_letter.get_branch_name()?, most_recent_proposal_patch_chain, ) .context("cannot apply patch chain")?; @@ -496,7 +496,7 @@ pub async fn launch() -> Result<()> { } 1 => { check_clean(&git_repo)?; - git_repo.checkout(&cover_letter.branch_name)?; + git_repo.checkout(&cover_letter.get_branch_name()?)?; println!( "checked out old proposal in existing branch ({} ahead {} behind '{main_branch_name}')", local_ahead_of_main.len(), @@ -537,7 +537,7 @@ pub async fn launch() -> Result<()> { ]), )? { 0 => { - git_repo.checkout(&cover_letter.branch_name)?; + git_repo.checkout(&cover_letter.get_branch_name()?)?; println!( "checked out proposal branch with {} unpublished commits ({} ahead {} behind '{main_branch_name}')", local_ahead_of_proposal.len(), @@ -604,7 +604,7 @@ pub async fn launch() -> Result<()> { )? { 0 => { check_clean(&git_repo)?; - git_repo.checkout(&cover_letter.branch_name)?; + git_repo.checkout(&cover_letter.get_branch_name()?)?; println!( "checked out old proposal in existing branch ({} ahead {} behind '{main_branch_name}')", local_ahead_of_main.len(), @@ -615,15 +615,18 @@ pub async fn launch() -> Result<()> { 1 => { check_clean(&git_repo)?; git_repo.create_branch_at_commit( - &cover_letter.branch_name, + &cover_letter.get_branch_name()?, &proposal_base_commit.to_string(), )?; let chain_length = most_recent_proposal_patch_chain.len(); let _ = git_repo - .apply_patch_chain(&cover_letter.branch_name, most_recent_proposal_patch_chain) + .apply_patch_chain( + &cover_letter.get_branch_name()?, + most_recent_proposal_patch_chain, + ) .context("cannot apply patch chain")?; - git_repo.checkout(&cover_letter.branch_name)?; + git_repo.checkout(&cover_letter.get_branch_name()?)?; println!( "checked out latest version of proposal ({} ahead {} behind '{main_branch_name}'), replacing unpublished version ({} ahead {} behind '{main_branch_name}')", chain_length, -- cgit v1.2.3