From 8196027f3528e344df19253c3fb643b02d51440e Mon Sep 17 00:00:00 2001 From: cloudhead Date: Mon, 11 Dec 2023 11:28:29 +0100 Subject: [PATCH] cli: Allow force-push with single delegates It's not currently possible to force-push rad/master if it's not a rollback, even if you are the only delegate. Since there is no risk in doing that, we allow it in this patch. --- radicle-remote-helper/src/push.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/radicle-remote-helper/src/push.rs b/radicle-remote-helper/src/push.rs index f43963ad..189a34b9 100644 --- a/radicle-remote-helper/src/push.rs +++ b/radicle-remote-helper/src/push.rs @@ -226,11 +226,15 @@ pub fn run( let (canonical_ref, canonical_oid) = &canonical; // If we're trying to update the canonical head, make sure - // we don't diverge from the current head. + // we don't diverge from the current head. This only applies + // to repos with more than one delegate. // // Note that we *do* allow rolling back to a previous commit on the // canonical branch. - if dst == *canonical_ref && delegates.contains(&Did::from(nid)) { + if dst == *canonical_ref + && delegates.contains(&Did::from(nid)) + && delegates.len() > 1 + { let head = working.find_reference(src.as_str())?; let head = head.peel_to_commit()?.id(); // Rollback is allowed and head is an ancestor of the canonical head.