Skip to content

Commit

Permalink
Don't print in case of failed self-update
Browse files Browse the repository at this point in the history
  • Loading branch information
grahnen committed Dec 10, 2024
1 parent ed6b2ff commit b95dfc1
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/steps/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,20 +260,23 @@ pub fn run_elan(ctx: &ExecutionContext) -> Result<()> {
print_separator("elan");

let disabled = "self-update is disabled";
let mut exec = ctx.run_type().execute(&elan);
let mut success = true;
if let Err(e) = exec.arg("self").arg("update").status_checked() {
error!("Self-update failed: {e}");
if let Err(e) = exec.output_checked_utf8() {
success = match e.downcast_ref::<TopgradeError>() {
Some(TopgradeError::ProcessFailedWithOutput(_, _, stderr)) => stderr.contains(disabled),
_ => false,
}

let res = ctx.run_type()
.execute(&elan)
.args(["self", "update"])
.output_checked();

// Ignore failed self-update if it is disabled
if let Err(e) = &res {
success = match e.downcast_ref::<TopgradeError>() {
Some(TopgradeError::ProcessFailedWithOutput(_, _, stderr)) => stderr.contains(disabled),
_ => false,
}
}

if !success {
return Err(eyre!(StepFailed));
return Err(res.err().unwrap());
}

ctx.run_type().execute(&elan).arg("update").status_checked()
Expand Down

0 comments on commit b95dfc1

Please sign in to comment.