From 5efd99a6e0a229d40106811188f6afd58dd97399 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 6 Nov 2019 12:40:28 +0300 Subject: Ignore line-endings when checking generated files for freshness closes #2184 --- xtask/src/codegen.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs index 4ec8ab75a..770b55a9a 100644 --- a/xtask/src/codegen.rs +++ b/xtask/src/codegen.rs @@ -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 { -- cgit v1.2.3