Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: idempotent `rad id update`
Fintan Halpenny committed 1 year ago
commit 80f1e6516cfb2412988c72deb3dd024c2a920bf3
parent 42ffbf3fe66b5d7a78604bd3c7d73f57ef9e9487
4 files changed +14 -16
modified radicle-cli/examples/rad-id-private.md
@@ -62,17 +62,16 @@ $ rad id update --title "Remove allow list" --allow did:key:z6Mkt67GdsW7715MEfRu
✗ Error: `--allow` and `--disallow` must not overlap: ["did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk"]
```

-
Allowing or disallowing the same peer twice will result in an error the second
-
call, since there is no update specified:
+
Allowing or disallowing the same peer twice will result in a message saying that
+
the document is already up to date:

```
$ rad id update --title "Allow Bob" --allow did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk -q
...
```
-
``` (fails)
-
$ rad id update --title "Allow Bob" --allow did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk -q
-
✗ Error: no update specified
-
✗ Hint: an update to the identity must be specified, run `rad id update -h` to see the available options
+
```
+
$ rad id update --title "Allow Bob" --allow did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk
+
Nothing to do. The document is up to date. See `rad inspect --identity`.
```

If we attempt to change the list while also changing the repository to `public`,
modified radicle-cli/examples/rad-id-update-delete-field.md
@@ -74,5 +74,5 @@ Note that we cannot delete mandatory fields:

``` (fails)
$ rad id update --title "Delete default branch" --payload xyz.radicle.project defaultBranch null
-
✗ Error: failed to verify `xyz.radicle.project`, failed with json: missing field `defaultBranch`
+
✗ Error: failed to verify `xyz.radicle.project`, json: missing field `defaultBranch`
```
modified radicle-cli/examples/rad-id.md
@@ -174,10 +174,9 @@ $ rad id accept 0ca42d376bd566631083c8913cf86bec722da392
✗ Error: [..]
```

-
If no updates are specified then the update will fail:
+
If no updates are specified then we are told that our command had no effect:

-
``` (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
+
Nothing to do. The document is up to date. See `rad inspect --identity`.
```
modified radicle-cli/src/commands/id.rs
@@ -465,15 +465,15 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
                // Verify that the project payload can still be parsed into the
                // `Project` type.
                if let Err(e) = proposal.project() {
-
                    anyhow::bail!("failed to verify `xyz.radicle.project`, failed with {e}",);
+
                    anyhow::bail!("failed to verify `xyz.radicle.project`, {e}");
                }
                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());
+
                term::print(term::format::italic(
+
                    "Nothing to do. The document is up to date. See `rad inspect --identity`.",
+
                ));
+
                return Ok(());
            }
            let revision = update(title, description, proposal, &mut identity, &signer)?;