Rollup merge of #125625 - ChrisDenton:line-endings, r=Mark-Simulacrum

Use grep to implement verify-line-endings

Unless I'm missing something (which I might be!) then `verify-line-endings` is easy to implement with `grep` rather than using a bespoke tool with varying availability.
This commit is contained in:
Matthias Krüger 2024-05-27 20:43:26 +02:00 committed by GitHub
commit 4966e1ae35
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,21 +4,21 @@
# We check both in rust-lang/rust and in a submodule to make sure both are # We check both in rust-lang/rust and in a submodule to make sure both are
# accurate. Submodules are checked out significantly later than the main # accurate. Submodules are checked out significantly later than the main
# repository in this script, so settings can (and do!) change between then. # repository in this script, so settings can (and do!) change between then.
#
# Linux (and maybe macOS) builders don't currently have dos2unix so just only
# run this step on Windows.
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'
source "$(cd "$(dirname "$0")" && pwd)/../shared.sh" source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
if isWindows; then # print out the git configuration so we can better investigate failures in
# print out the git configuration so we can better investigate failures in # the following
# the following git config --list --show-origin
git config --list --show-origin # -U is necessary on Windows to stop grep automatically converting the line ending
dos2unix -ih Cargo.lock src/tools/rust-installer/install-template.sh endings=$(grep -Ul $(printf '\r$') Cargo.lock src/tools/cargo/Cargo.lock) || true
endings=$(dos2unix -ic Cargo.lock src/tools/rust-installer/install-template.sh) # if endings has non-zero length, error out
# if endings has non-zero length, error out if [[ -n $endings ]]; then
if [ -n "$endings" ]; then exit 1 ; fi echo "Error: found DOS line endings"
# Print the files with DOS line endings
echo "$endings"
exit 1
fi fi