2188: Ignore line-endings when checking generated files for freshness r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2019-11-06 09:41:33 +00:00 committed by GitHub
commit d222608a45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -46,7 +46,7 @@ pub enum Mode {
/// With verify = false,
fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> {
match fs::read_to_string(path) {
Ok(ref old_contents) if old_contents == contents => {
Ok(ref old_contents) if normalize(old_contents) == normalize(contents) => {
return Ok(());
}
_ => (),
@ -56,7 +56,11 @@ fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> {
}
eprintln!("updating {}", path.display());
fs::write(path, contents)?;
Ok(())
return Ok(());
fn normalize(s: &str) -> String {
s.replace("\r\n", "\n")
}
}
fn reformat(text: impl std::fmt::Display) -> Result<String> {