Skip to content

Commit

Permalink
Change --fix-only exit semantics to mirror --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Apr 29, 2023
1 parent 03144b2 commit 12366ac
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions crates/ruff_cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,17 +280,27 @@ fn check(args: CheckArgs, log_level: LogLevel) -> Result<ExitStatus> {
}

if !cli.exit_zero {
if cli.diff || fix_only {
if cli.diff {
if !diagnostics.fixed.is_empty() {
return Ok(ExitStatus::Failure);
}
} else if cli.exit_non_zero_on_fix {
if !diagnostics.fixed.is_empty() || !diagnostics.messages.is_empty() {
return Ok(ExitStatus::Failure);
} else if fix_only {
if cli.exit_non_zero_on_fix {
if !diagnostics.fixed.is_empty() {
return Ok(ExitStatus::Failure);
}
} else {
return Ok(ExitStatus::Success);
}
} else {
if !diagnostics.messages.is_empty() {
return Ok(ExitStatus::Failure);
if cli.exit_non_zero_on_fix {
if !diagnostics.fixed.is_empty() || !diagnostics.messages.is_empty() {
return Ok(ExitStatus::Failure);
}
} else {
if !diagnostics.messages.is_empty() {
return Ok(ExitStatus::Failure);
}
}
}
}
Expand Down

0 comments on commit 12366ac

Please sign in to comment.