From f6d1e03dc99b3ea48cb6e4bd1d3371dd924a567a Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 5 Mar 2026 21:25:50 +0000 Subject: fix(pr-checkout): require --force on diverged proposal branch checkout_patch() previously re-applied the patch chain whenever the local branch tip didn't match the published tip, silently overwriting local amendments and rebased revisions without warning. Now detects the relationship between local and published tips: - up to date: check out as-is - behind (local is ancestor of published): fast-forward, no flag needed - local commits on top (published is ancestor of local): check out as-is - diverged (neither ancestor): bail with guidance, --force to overwrite - published tip not found locally and branch exists: same as diverged Also adds --force flag to `ngit pr checkout` to explicitly opt in to overwriting a diverged branch, covering both local amendments and author force-pushes. Bug discovered during test implementation in tests/ngit_pr_checkout.rs. --- src/bin/ngit/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/bin/ngit/main.rs') diff --git a/src/bin/ngit/main.rs b/src/bin/ngit/main.rs index 215d5dd..599fbe2 100644 --- a/src/bin/ngit/main.rs +++ b/src/bin/ngit/main.rs @@ -97,8 +97,8 @@ async fn main() { ) .await } - PrCommands::Checkout { id, offline } => { - sub_commands::checkout::launch(id, *offline).await + PrCommands::Checkout { id, force, offline } => { + sub_commands::checkout::launch(id, *force, *offline).await } PrCommands::Apply { id, -- cgit v1.2.3