Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
cli: Display errors in `patch ready` when wrong type of patch is provided
Merged did:key:z6MkkfM3...sVz5 opened 2 years ago

Instead of doing nothing and going to sync no change, we should display some error to the users that we haven’t been able to apply the changes.

2 files changed +12 -5 0a78b9cc d38846ba
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(())
}