From 16a78526cedfdb9af5d6befce3c77436aabc9a2f Mon Sep 17 00:00:00 2001 From: Jonathan Pallant Date: Mon, 25 Nov 2024 11:26:47 +0000 Subject: [PATCH] generate-copyright: Ensure output has UNIX line-endings for consistency. --- src/tools/generate-copyright/src/main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tools/generate-copyright/src/main.rs b/src/tools/generate-copyright/src/main.rs index f9d96b594626..f83d16d0cabf 100644 --- a/src/tools/generate-copyright/src/main.rs +++ b/src/tools/generate-copyright/src/main.rs @@ -57,6 +57,10 @@ fn main() -> Result<(), Error> { dependencies: collected_cargo_metadata, }; let output = template.render()?; + // Git stores text files with \n, but this file may contain \r\n in files + // copied from dependencies. Normalise them before we write them out, for + // consistency. + let output = output.replace("\r\n", "\n"); std::fs::write(&dest_file, output)?; // Output libstd subset file @@ -65,6 +69,10 @@ fn main() -> Result<(), Error> { dependencies: library_collected_cargo_metadata, }; let output = template.render()?; + // Git stores text files with \n, but this file may contain \r\n in files + // copied from dependencies. Normalise them before we write them out, for + // consistency. + let output = output.replace("\r\n", "\n"); std::fs::write(&libstd_dest_file, output)?; Ok(())