mirror of
https://github.com/casey/just.git
synced 2024-11-23 11:04:09 +03:00
Suppress --fmt --check diff if --quiet is passed (#1457)
This commit is contained in:
parent
fbe1c4c7a3
commit
9887582497
@ -374,21 +374,23 @@ impl Subcommand {
|
|||||||
return if formatted == src {
|
return if formatted == src {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
use similar::{ChangeTag, TextDiff};
|
if !config.verbosity.quiet() {
|
||||||
|
use similar::{ChangeTag, TextDiff};
|
||||||
|
|
||||||
let diff = TextDiff::configure()
|
let diff = TextDiff::configure()
|
||||||
.algorithm(similar::Algorithm::Patience)
|
.algorithm(similar::Algorithm::Patience)
|
||||||
.diff_lines(src, &formatted);
|
.diff_lines(src, &formatted);
|
||||||
|
|
||||||
for op in diff.ops() {
|
for op in diff.ops() {
|
||||||
for change in diff.iter_changes(op) {
|
for change in diff.iter_changes(op) {
|
||||||
let (symbol, color) = match change.tag() {
|
let (symbol, color) = match change.tag() {
|
||||||
ChangeTag::Delete => ("-", config.color.stderr().diff_deleted()),
|
ChangeTag::Delete => ("-", config.color.stderr().diff_deleted()),
|
||||||
ChangeTag::Equal => (" ", config.color.stderr()),
|
ChangeTag::Equal => (" ", config.color.stderr()),
|
||||||
ChangeTag::Insert => ("+", config.color.stderr().diff_added()),
|
ChangeTag::Insert => ("+", config.color.stderr().diff_added()),
|
||||||
};
|
};
|
||||||
|
|
||||||
eprint!("{}{symbol}{change}{}", color.prefix(), color.suffix());
|
eprint!("{}{symbol}{change}{}", color.prefix(), color.suffix());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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",
|
||||||
|
Loading…
Reference in New Issue
Block a user