Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: Display better errors in `patch ready`
Sebastian Martinez committed 2 years ago
commit d38846baaeeb0bcfb9b19d3a6819a0aa87367042
parent 0a78b9cc5b25866a0df2231f9bea71fbfc0aa975
2 files changed +12 -5
modified radicle-cli/src/commands/patch.rs
@@ -743,7 +743,14 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
        }
        Operation::Ready { ref patch_id, undo } => {
            let patch_id = patch_id.resolve::<PatchId>(&repository.backend)?;
-
            ready::run(&patch_id, undo, &profile, &repository)?;
+

+
            if !ready::run(&patch_id, undo, &profile, &repository)? {
+
                if undo {
+
                    anyhow::bail!("the patch must be open to be put in draft state");
+
                } else {
+
                    anyhow::bail!("this patch must be in draft state to be put in open state");
+
                }
+
            }
        }
        Operation::Delete { patch_id } => {
            let patch_id = patch_id.resolve::<PatchId>(&repository.backend)?;
modified radicle-cli/src/commands/patch/ready.rs
@@ -8,7 +8,7 @@ pub fn run(
    undo: bool,
    profile: &Profile,
    repository: &Repository,
-
) -> anyhow::Result<()> {
+
) -> anyhow::Result<bool> {
    let signer = term::signer(profile)?;
    let mut patches = profile.patches_mut(repository)?;
    let Ok(mut patch) = patches.get_mut(patch_id) else {
@@ -16,9 +16,9 @@ pub fn run(
    };

    if undo {
-
        patch.unready(&signer)?;
+
        patch.unready(&signer)
    } else {
-
        patch.ready(&signer)?;
+
        patch.ready(&signer)
    }
-
    Ok(())
+
    .map_err(anyhow::Error::from)
}