Suppress --fmt --check diff if --quiet is passed (#1457)

This commit is contained in:
Casey Rodarmor 2022-12-20 20:57:58 -08:00 committed by GitHub
parent fbe1c4c7a3
commit 9887582497
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 12 deletions

View File

@ -374,6 +374,7 @@ impl Subcommand {
return if formatted == src { return if formatted == src {
Ok(()) Ok(())
} else { } else {
if !config.verbosity.quiet() {
use similar::{ChangeTag, TextDiff}; use similar::{ChangeTag, TextDiff};
let diff = TextDiff::configure() let diff = TextDiff::configure()
@ -391,6 +392,7 @@ impl Subcommand {
eprint!("{}{symbol}{change}{}", color.prefix(), color.suffix()); eprint!("{}{symbol}{change}{}", color.prefix(), color.suffix());
} }
} }
}
Err(Error::FormatCheckFoundDiff) Err(Error::FormatCheckFoundDiff)
}; };

View File

@ -53,6 +53,14 @@ test! {
status: EXIT_FAILURE, status: EXIT_FAILURE,
} }
test! {
name: check_found_diff_quiet,
justfile: "x:=``\n",
args: ("--unstable", "--fmt", "--check", "--quiet"),
stderr: "",
status: EXIT_FAILURE,
}
test! { test! {
name: check_diff_color, name: check_diff_color,
justfile: "x:=``\n", justfile: "x:=``\n",