mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Merge pull request #1123 from juicejitsu/807
Don't emit filename in diff mode, add filename to diff metadata
This commit is contained in:
commit
e1759ae295
@ -144,11 +144,11 @@ pub fn write_file<T>(text: &StringBuffer,
|
|||||||
try!(write_system_newlines(stdout, text, config));
|
try!(write_system_newlines(stdout, text, config));
|
||||||
}
|
}
|
||||||
WriteMode::Diff => {
|
WriteMode::Diff => {
|
||||||
println!("Diff of {}:\n", filename);
|
|
||||||
if let Ok((ori, fmt)) = source_and_formatted_text(text, filename, config) {
|
if let Ok((ori, fmt)) = source_and_formatted_text(text, filename, config) {
|
||||||
let mismatch = make_diff(&ori, &fmt, 3);
|
let mismatch = make_diff(&ori, &fmt, 3);
|
||||||
let has_diff = !mismatch.is_empty();
|
let has_diff = !mismatch.is_empty();
|
||||||
print_diff(mismatch, |line_num| format!("\nDiff at line {}:", line_num));
|
print_diff(mismatch,
|
||||||
|
|line_num| format!("Diff in {} at line {}:", filename, line_num));
|
||||||
return Ok(has_diff);
|
return Ok(has_diff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -365,3 +365,9 @@ fn rustfmt_diff_make_diff_tests() {
|
|||||||
DiffLine::Context("d".into())],
|
DiffLine::Context("d".into())],
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn rustfmt_diff_no_diff_test() {
|
||||||
|
let diff = make_diff("a\nb\nc\nd", "a\nb\nc\nd", 3);
|
||||||
|
assert_eq!(diff, vec![]);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user