Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: Display errors in `patch ready` when wrong type of patch is provided
✗ CI failure Sebastian Martinez committed 2 years ago
commit 4c2e0769550fd430169fcd5b07f4261845da26f2
parent 54aacc96197a48b79fcc260f94312d824f5e0a34
1 failed (1 total) View logs
2 files changed +12 -5
modified radicle-cli/src/commands/patch.rs
@@ -732,7 +732,15 @@ 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)?;
+
            let result = ready::run(&patch_id, undo, &profile, &repository)?;
+
            let error_msg = if undo {
+
                "this command is only able to put open patches back into draft state"
+
            } else {
+
                "this command is only able to put draft patches into open state"
+
            };
+
            if result == false {
+
                return Err(anyhow!(error_msg));
+
            }
        }
        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,8 @@ pub fn run(
    };

    if undo {
-
        patch.unready(&signer)?;
+
        Ok(patch.unready(&signer)?)
    } else {
-
        patch.ready(&signer)?;
+
        Ok(patch.ready(&signer)?)
    }
-
    Ok(())
}