Print format diff to stdout (#1506)
This commit is contained in:
parent
3bf3be9af8
commit
1d02f0ef80
@ -383,12 +383,12 @@ impl Subcommand {
|
||||
for op in diff.ops() {
|
||||
for change in diff.iter_changes(op) {
|
||||
let (symbol, color) = match change.tag() {
|
||||
ChangeTag::Delete => ("-", config.color.stderr().diff_deleted()),
|
||||
ChangeTag::Equal => (" ", config.color.stderr()),
|
||||
ChangeTag::Insert => ("+", config.color.stderr().diff_added()),
|
||||
ChangeTag::Delete => ("-", config.color.stdout().diff_deleted()),
|
||||
ChangeTag::Equal => (" ", config.color.stdout()),
|
||||
ChangeTag::Insert => ("+", config.color.stdout().diff_added()),
|
||||
};
|
||||
|
||||
eprint!("{}{symbol}{change}{}", color.prefix(), color.suffix());
|
||||
print!("{}{symbol}{change}{}", color.prefix(), color.suffix());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
10
tests/fmt.rs
10
tests/fmt.rs
@ -45,9 +45,11 @@ test! {
|
||||
name: check_found_diff,
|
||||
justfile: "x:=``\n",
|
||||
args: ("--unstable", "--fmt", "--check"),
|
||||
stderr: "
|
||||
stdout: "
|
||||
-x:=``
|
||||
+x := ``
|
||||
",
|
||||
stderr: "
|
||||
error: Formatted justfile differs from original.
|
||||
",
|
||||
status: EXIT_FAILURE,
|
||||
@ -65,10 +67,12 @@ test! {
|
||||
name: check_diff_color,
|
||||
justfile: "x:=``\n",
|
||||
args: ("--unstable", "--fmt", "--check", "--color", "always"),
|
||||
stderr: "
|
||||
stdout: "
|
||||
\u{1b}[31m-x:=``
|
||||
\u{1b}[0m\u{1b}[32m+x := ``
|
||||
\u{1b}[0m\u{1b}[1;31merror\u{1b}[0m: \u{1b}[1mFormatted justfile differs from original.\u{1b}[0m
|
||||
\u{1b}[0m",
|
||||
stderr: "
|
||||
\u{1b}[1;31merror\u{1b}[0m: \u{1b}[1mFormatted justfile differs from original.\u{1b}[0m
|
||||
",
|
||||
status: EXIT_FAILURE,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user