upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/bin/ngit/cli.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-03-05 21:25:50 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-03-05 22:12:07 +0000
commitf6d1e03dc99b3ea48cb6e4bd1d3371dd924a567a (patch)
tree19fb789e83bd8d4ccc25f735a80cf41c0eccad17 /src/bin/ngit/cli.rs
parent83b0886b97e2e90e328f91fcfaeb59726c93308f (diff)
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.
Diffstat (limited to 'src/bin/ngit/cli.rs')
-rw-r--r--src/bin/ngit/cli.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/bin/ngit/cli.rs b/src/bin/ngit/cli.rs
index 018525c..2919c72 100644
--- a/src/bin/ngit/cli.rs
+++ b/src/bin/ngit/cli.rs
@@ -220,6 +220,10 @@ pub enum PrCommands {
220 /// Proposal event-id (hex) or nevent (bech32) 220 /// Proposal event-id (hex) or nevent (bech32)
221 #[arg(value_name = "ID|nevent")] 221 #[arg(value_name = "ID|nevent")]
222 id: String, 222 id: String,
223 /// Overwrite local branch even if it has diverged from the published
224 /// proposal
225 #[arg(long)]
226 force: bool,
223 /// Use local cache only, skip network fetch 227 /// Use local cache only, skip network fetch
224 #[arg(long)] 228 #[arg(long)]
225 offline: bool, 229 offline: bool,