upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/sub_commands/list.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-07-23 16:36:06 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2024-07-23 16:36:06 +0100
commitb67376ff54abeab31422921ba5f4883d5d3dccdb (patch)
treed4f4194fdf2d285332dd7aacea31678042389b00 /src/sub_commands/list.rs
parent643fa17fde858c2d6f934dcc435eb84843cc172e (diff)
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
Diffstat (limited to 'src/sub_commands/list.rs')
-rw-r--r--src/sub_commands/list.rs39
1 files changed, 21 insertions, 18 deletions
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<()> {
263 .get_local_branch_names() 263 .get_local_branch_names()
264 .context("gitlib2 will not show a list of local branch names")? 264 .context("gitlib2 will not show a list of local branch names")?
265 .iter() 265 .iter()
266 .any(|n| n.eq(&cover_letter.branch_name)); 266 .any(|n| n.eq(&cover_letter.get_branch_name().unwrap()));
267 267
268 let checked_out_proposal_branch = git_repo 268 let checked_out_proposal_branch = git_repo
269 .get_checked_out_branch_name()? 269 .get_checked_out_branch_name()?
270 .eq(&cover_letter.branch_name); 270 .eq(&cover_letter.get_branch_name()?);
271 271
272 let proposal_base_commit = str_to_sha1(&tag_value( 272 let proposal_base_commit = str_to_sha1(&tag_value(
273 most_recent_proposal_patch_chain.last().context( 273 most_recent_proposal_patch_chain.last().context(
@@ -329,14 +329,14 @@ pub async fn launch() -> Result<()> {
329 check_clean(&git_repo)?; 329 check_clean(&git_repo)?;
330 let _ = git_repo 330 let _ = git_repo
331 .apply_patch_chain( 331 .apply_patch_chain(
332 &cover_letter.branch_name, 332 &cover_letter.get_branch_name()?,
333 most_recent_proposal_patch_chain, 333 most_recent_proposal_patch_chain,
334 ) 334 )
335 .context("cannot apply patch chain")?; 335 .context("cannot apply patch chain")?;
336 336
337 println!( 337 println!(
338 "checked out proposal as '{}' branch", 338 "checked out proposal as '{}' branch",
339 cover_letter.branch_name 339 cover_letter.get_branch_name()?
340 ); 340 );
341 Ok(()) 341 Ok(())
342 } 342 }
@@ -349,7 +349,7 @@ pub async fn launch() -> Result<()> {
349 }; 349 };
350 } 350 }
351 351
352 let local_branch_tip = git_repo.get_tip_of_branch(&cover_letter.branch_name)?; 352 let local_branch_tip = git_repo.get_tip_of_branch(&cover_letter.get_branch_name()?)?;
353 353
354 // up-to-date 354 // up-to-date
355 if proposal_tip.eq(&local_branch_tip) { 355 if proposal_tip.eq(&local_branch_tip) {
@@ -384,10 +384,10 @@ pub async fn launch() -> Result<()> {
384 )? { 384 )? {
385 0 => { 385 0 => {
386 check_clean(&git_repo)?; 386 check_clean(&git_repo)?;
387 git_repo.checkout(&cover_letter.branch_name)?; 387 git_repo.checkout(&cover_letter.get_branch_name()?)?;
388 println!( 388 println!(
389 "checked out proposal as '{}' branch", 389 "checked out proposal as '{}' branch",
390 cover_letter.branch_name 390 cover_letter.get_branch_name()?
391 ); 391 );
392 Ok(()) 392 Ok(())
393 } 393 }
@@ -421,10 +421,10 @@ pub async fn launch() -> Result<()> {
421 )? { 421 )? {
422 0 => { 422 0 => {
423 check_clean(&git_repo)?; 423 check_clean(&git_repo)?;
424 git_repo.checkout(&cover_letter.branch_name)?; 424 git_repo.checkout(&cover_letter.get_branch_name()?)?;
425 let _ = git_repo 425 let _ = git_repo
426 .apply_patch_chain( 426 .apply_patch_chain(
427 &cover_letter.branch_name, 427 &cover_letter.get_branch_name()?,
428 most_recent_proposal_patch_chain, 428 most_recent_proposal_patch_chain,
429 ) 429 )
430 .context("cannot apply patch chain")?; 430 .context("cannot apply patch chain")?;
@@ -474,14 +474,14 @@ pub async fn launch() -> Result<()> {
474 0 => { 474 0 => {
475 check_clean(&git_repo)?; 475 check_clean(&git_repo)?;
476 git_repo.create_branch_at_commit( 476 git_repo.create_branch_at_commit(
477 &cover_letter.branch_name, 477 &cover_letter.get_branch_name()?,
478 &proposal_base_commit.to_string(), 478 &proposal_base_commit.to_string(),
479 )?; 479 )?;
480 git_repo.checkout(&cover_letter.branch_name)?; 480 git_repo.checkout(&cover_letter.get_branch_name()?)?;
481 let chain_length = most_recent_proposal_patch_chain.len(); 481 let chain_length = most_recent_proposal_patch_chain.len();
482 let _ = git_repo 482 let _ = git_repo
483 .apply_patch_chain( 483 .apply_patch_chain(
484 &cover_letter.branch_name, 484 &cover_letter.get_branch_name()?,
485 most_recent_proposal_patch_chain, 485 most_recent_proposal_patch_chain,
486 ) 486 )
487 .context("cannot apply patch chain")?; 487 .context("cannot apply patch chain")?;
@@ -496,7 +496,7 @@ pub async fn launch() -> Result<()> {
496 } 496 }
497 1 => { 497 1 => {
498 check_clean(&git_repo)?; 498 check_clean(&git_repo)?;
499 git_repo.checkout(&cover_letter.branch_name)?; 499 git_repo.checkout(&cover_letter.get_branch_name()?)?;
500 println!( 500 println!(
501 "checked out old proposal in existing branch ({} ahead {} behind '{main_branch_name}')", 501 "checked out old proposal in existing branch ({} ahead {} behind '{main_branch_name}')",
502 local_ahead_of_main.len(), 502 local_ahead_of_main.len(),
@@ -537,7 +537,7 @@ pub async fn launch() -> Result<()> {
537 ]), 537 ]),
538 )? { 538 )? {
539 0 => { 539 0 => {
540 git_repo.checkout(&cover_letter.branch_name)?; 540 git_repo.checkout(&cover_letter.get_branch_name()?)?;
541 println!( 541 println!(
542 "checked out proposal branch with {} unpublished commits ({} ahead {} behind '{main_branch_name}')", 542 "checked out proposal branch with {} unpublished commits ({} ahead {} behind '{main_branch_name}')",
543 local_ahead_of_proposal.len(), 543 local_ahead_of_proposal.len(),
@@ -604,7 +604,7 @@ pub async fn launch() -> Result<()> {
604 )? { 604 )? {
605 0 => { 605 0 => {
606 check_clean(&git_repo)?; 606 check_clean(&git_repo)?;
607 git_repo.checkout(&cover_letter.branch_name)?; 607 git_repo.checkout(&cover_letter.get_branch_name()?)?;
608 println!( 608 println!(
609 "checked out old proposal in existing branch ({} ahead {} behind '{main_branch_name}')", 609 "checked out old proposal in existing branch ({} ahead {} behind '{main_branch_name}')",
610 local_ahead_of_main.len(), 610 local_ahead_of_main.len(),
@@ -615,15 +615,18 @@ pub async fn launch() -> Result<()> {
615 1 => { 615 1 => {
616 check_clean(&git_repo)?; 616 check_clean(&git_repo)?;
617 git_repo.create_branch_at_commit( 617 git_repo.create_branch_at_commit(
618 &cover_letter.branch_name, 618 &cover_letter.get_branch_name()?,
619 &proposal_base_commit.to_string(), 619 &proposal_base_commit.to_string(),
620 )?; 620 )?;
621 let chain_length = most_recent_proposal_patch_chain.len(); 621 let chain_length = most_recent_proposal_patch_chain.len();
622 let _ = git_repo 622 let _ = git_repo
623 .apply_patch_chain(&cover_letter.branch_name, most_recent_proposal_patch_chain) 623 .apply_patch_chain(
624 &cover_letter.get_branch_name()?,
625 most_recent_proposal_patch_chain,
626 )
624 .context("cannot apply patch chain")?; 627 .context("cannot apply patch chain")?;
625 628
626 git_repo.checkout(&cover_letter.branch_name)?; 629 git_repo.checkout(&cover_letter.get_branch_name()?)?;
627 println!( 630 println!(
628 "checked out latest version of proposal ({} ahead {} behind '{main_branch_name}'), replacing unpublished version ({} ahead {} behind '{main_branch_name}')", 631 "checked out latest version of proposal ({} ahead {} behind '{main_branch_name}'), replacing unpublished version ({} ahead {} behind '{main_branch_name}')",
629 chain_length, 632 chain_length,