diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-02-22 16:20:20 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-02-22 16:20:20 +0000 |
| commit | 362468193b935d56f52981a43b0a1f31a83ee571 (patch) | |
| tree | 9e9331069181cd360081af55a3c1b0073abf6550 /src/sub_commands/list.rs | |
| parent | 9f1d8cd964a04197565a2acb1f2b174c9582d333 (diff) | |
refactor(list): improve copy
reduce wording in choices
Diffstat (limited to 'src/sub_commands/list.rs')
| -rw-r--r-- | src/sub_commands/list.rs | 53 |
1 files changed, 23 insertions, 30 deletions
diff --git a/src/sub_commands/list.rs b/src/sub_commands/list.rs index a815cc3..7f0622e 100644 --- a/src/sub_commands/list.rs +++ b/src/sub_commands/list.rs | |||
| @@ -477,8 +477,6 @@ pub async fn launch(_cli_args: &Cli, _args: &SubCommandArgs) -> Result<()> { | |||
| 477 | }; | 477 | }; |
| 478 | } | 478 | } |
| 479 | 479 | ||
| 480 | // TODO: write tests | ||
| 481 | |||
| 482 | println!("you have an ammended/rebase version the proposal that is unpublished"); | 480 | println!("you have an ammended/rebase version the proposal that is unpublished"); |
| 483 | // user probably has a unpublished ammended or rebase version of the latest | 481 | // user probably has a unpublished ammended or rebase version of the latest |
| 484 | // proposal version | 482 | // proposal version |
| @@ -518,27 +516,16 @@ pub async fn launch(_cli_args: &Cli, _args: &SubCommandArgs) -> Result<()> { | |||
| 518 | println!("if you are confident in your changes consider running `ngit push --force`"); | 516 | println!("if you are confident in your changes consider running `ngit push --force`"); |
| 519 | 517 | ||
| 520 | return match Interactor::default().choice( | 518 | return match Interactor::default().choice( |
| 521 | PromptChoiceParms::default().with_default(0) | 519 | PromptChoiceParms::default() |
| 522 | .with_choices( | 520 | .with_default(0) |
| 523 | vec![ | 521 | .with_choices(vec![ |
| 524 | format!( | 522 | format!("checkout local branch with unpublished changes"), |
| 525 | "checkout local branch with unpublished changes ({} ahead {} behind '{main_branch_name}')", | 523 | format!("discard unpublished changes and checkout new revision",), |
| 526 | local_ahead_of_main.len(), | ||
| 527 | local_beind_main.len(), | ||
| 528 | ), | ||
| 529 | format!( | ||
| 530 | "discard local branch with old version ({} ahead {} behind '{main_branch_name}') and checkout latest published version ({} ahead {} behind '{main_branch_name}')", | ||
| 531 | most_recent_proposal_patch_chain.len(), | ||
| 532 | proposal_behind_main.len(), | ||
| 533 | local_ahead_of_main.len(), | ||
| 534 | local_beind_main.len(), | ||
| 535 | ), | ||
| 536 | format!("apply to current branch with `git am`"), | 524 | format!("apply to current branch with `git am`"), |
| 537 | format!("download to ./patches"), | 525 | format!("download to ./patches"), |
| 538 | "back".to_string(), | 526 | "back".to_string(), |
| 539 | ], | 527 | ]), |
| 540 | ) | 528 | )? { |
| 541 | )? { | ||
| 542 | 0 => { | 529 | 0 => { |
| 543 | check_clean(&git_repo)?; | 530 | check_clean(&git_repo)?; |
| 544 | git_repo.checkout(&cover_letter.branch_name)?; | 531 | git_repo.checkout(&cover_letter.branch_name)?; |
| @@ -548,29 +535,35 @@ pub async fn launch(_cli_args: &Cli, _args: &SubCommandArgs) -> Result<()> { | |||
| 548 | local_beind_main.len(), | 535 | local_beind_main.len(), |
| 549 | ); | 536 | ); |
| 550 | Ok(()) | 537 | Ok(()) |
| 551 | }, | 538 | } |
| 552 | 1 => { | 539 | 1 => { |
| 553 | check_clean(&git_repo)?; | 540 | check_clean(&git_repo)?; |
| 554 | git_repo.create_branch_at_commit(&cover_letter.branch_name, &proposal_base_commit.to_string())?; | 541 | git_repo.create_branch_at_commit( |
| 555 | git_repo.checkout(&cover_letter.branch_name)?; | 542 | &cover_letter.branch_name, |
| 543 | &proposal_base_commit.to_string(), | ||
| 544 | )?; | ||
| 556 | let chain_length = most_recent_proposal_patch_chain.len(); | 545 | let chain_length = most_recent_proposal_patch_chain.len(); |
| 557 | let _ = git_repo | 546 | let _ = git_repo |
| 558 | .apply_patch_chain(&cover_letter.branch_name, most_recent_proposal_patch_chain) | 547 | .apply_patch_chain(&cover_letter.branch_name, most_recent_proposal_patch_chain) |
| 559 | .context("cannot apply patch chain")?; | 548 | .context("cannot apply patch chain")?; |
| 549 | |||
| 550 | git_repo.checkout(&cover_letter.branch_name)?; | ||
| 560 | println!( | 551 | println!( |
| 561 | "checked out new version of proposal ({} ahead {} behind '{main_branch_name}'), replacing old version ({} ahead {} behind '{main_branch_name}')", | 552 | "checked out latest version of proposal ({} ahead {} behind '{main_branch_name}'), replacing unpublished version ({} ahead {} behind '{main_branch_name}')", |
| 562 | chain_length, | 553 | chain_length, |
| 563 | proposal_behind_main.len(), | 554 | proposal_behind_main.len(), |
| 564 | local_ahead_of_main.len(), | 555 | local_ahead_of_main.len(), |
| 565 | local_beind_main.len(), | 556 | local_beind_main.len(), |
| 566 | ); | 557 | ); |
| 567 | Ok(()) | 558 | Ok(()) |
| 568 | }, | 559 | } |
| 569 | 2 => {launch_git_am_with_patches(most_recent_proposal_patch_chain)}, | 560 | 2 => launch_git_am_with_patches(most_recent_proposal_patch_chain), |
| 570 | 3 => {save_patches_to_dir(most_recent_proposal_patch_chain, &git_repo)}, | 561 | 3 => save_patches_to_dir(most_recent_proposal_patch_chain, &git_repo), |
| 571 | 4 => { continue }, | 562 | 4 => continue, |
| 572 | _ => { bail!("unexpected choice")} | 563 | _ => { |
| 573 | }; | 564 | bail!("unexpected choice") |
| 565 | } | ||
| 566 | }; | ||
| 574 | } | 567 | } |
| 575 | } | 568 | } |
| 576 | 569 | ||