From 9f9df6264ea48cedd4588e09e0fa103a2595c5cc Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Mon, 8 Jan 2024 09:55:40 +0000 Subject: [PATCH] cli: prevent identical revision for `rad patch update` Prevent `rad patch update` to create an identical revision to any other revision in the patch, rather than just the latest revision. Signed-off-by: Fintan Halpenny X-Clacks-Overhead: GNU Terry Pratchett --- radicle-cli/src/commands/patch/update.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/radicle-cli/src/commands/patch/update.rs b/radicle-cli/src/commands/patch/update.rs index aa70c733..0acff228 100644 --- a/radicle-cli/src/commands/patch/update.rs +++ b/radicle-cli/src/commands/patch/update.rs @@ -30,12 +30,16 @@ pub fn run( None => storage.backend.merge_base(*target_oid, *head_oid)?, }; - let (_, revision) = patch.latest(); - // N.b. we don't update if both the head and base are the same - if revision.head() == head_oid && **revision.base() == base_oid { + // N.b. we don't update if both the head and base are the same as + // any previous revision + if patch + .revisions() + .any(|(_, revision)| revision.head() == head_oid && **revision.base() == base_oid) + { return Ok(()); } + let (_, revision) = patch.latest(); let message = term::patch::get_update_message(message, workdir, revision, &head_oid)?; let signer = term::signer(profile)?; let revision = patch.update(message, base_oid, *head_oid, &signer)?;