cli: Display better errors in `patch ready`
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.
This commit is contained in:
parent
0a78b9cc5b
commit
d38846baae
|
|
@ -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)?;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue