From 18fc41c53f181673189dcca0213aafc38229c0f9 Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Thu, 7 Mar 2024 16:21:34 +0000 Subject: [PATCH] cli: error on no id update If `rad id` is called with no arguments, or just `--title` and `--description`, then it will fail because there were no changes made to the identity. Check if the `proposal` document is the same the `current` document, and if so supply a hint and a better error. Signed-off-by: Fintan Halpenny X-Clacks-Overhead: GNU Terry Pratchett --- radicle-cli/examples/rad-id.md | 8 ++++++++ radicle-cli/src/commands/id.rs | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/radicle-cli/examples/rad-id.md b/radicle-cli/examples/rad-id.md index f302d114..70a61d95 100644 --- a/radicle-cli/examples/rad-id.md +++ b/radicle-cli/examples/rad-id.md @@ -147,3 +147,11 @@ $ rad id update --title "Add Eve" --description "Add Eve as a delegate" --delega ✗ Error: missing delegate z6MkedT…47fovFn in local storage ✗ Error: fatal: refusing to update identity document ``` + +If no updates are specified then the update will fail: + +``` (fail) +$ rad id update --title "Update canonical branch" --description "Update the canonical branch to `main`" +✗ Error: no update specified +✗ Hint: an update to the identity must be specified, run `rad id update -h` to see the available options +``` diff --git a/radicle-cli/src/commands/id.rs b/radicle-cli/src/commands/id.rs index f73ffbfb..4722ccbe 100644 --- a/radicle-cli/src/commands/id.rs +++ b/radicle-cli/src/commands/id.rs @@ -380,6 +380,12 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { } proposal }; + if proposal == current.doc { + return Err(Error::WithHint { + err: anyhow!("no update specified"), + hint: "an update to the identity must be specified, run `rad id update -h` to see the available options" + }.into()); + } let revision = update(title, description, proposal, &mut identity, &signer)?; if revision.is_accepted() && revision.parent == Some(current.id) {