Add CI workflow to check line endings of all source files (#2082)
In addition, all found errors (formatting & line ending) have been fixed in this PR.
This commit is contained in:
@@ -4,12 +4,14 @@ set -eu
|
||||
|
||||
fail="0"
|
||||
|
||||
clang-format --version
|
||||
|
||||
while read -r file; do
|
||||
if ! diff -u <(cat "$file") <(clang-format "$file"); then
|
||||
echo "$file differs!!!!!!!"
|
||||
fail="1"
|
||||
fi
|
||||
done < <(find src/ \( -iname "*.hpp" -o -iname "*.cpp" \))
|
||||
done < <(find src/ -type f \( -iname "*.hpp" -o -iname "*.cpp" \))
|
||||
|
||||
if [ "$fail" = "1" ]; then
|
||||
echo "At least one file is poorly formatted - check the output above"
|
||||
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
fail="0"
|
||||
|
||||
dos2unix --version
|
||||
|
||||
while read -r file; do
|
||||
num_dos_line_endings=$(dos2unix -id "$file" | awk '/[0-9]+/{print $(NF-1)}')
|
||||
if [ "$num_dos_line_endings" -gt "0" ]; then
|
||||
>&2 echo "File '$file' contains $num_dos_line_endings DOS line-endings, it should only be using unix line-endings!"
|
||||
fail="1"
|
||||
fi
|
||||
done < <(find src/ -type f \( -iname "*.hpp" -o -iname "*.cpp" \))
|
||||
|
||||
if [ "$fail" = "1" ]; then
|
||||
>&2 echo "At least one file is not using unix line-endings - check the output above"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
>&2 echo "Every file seems to be using unix line-endings. Good job!"
|
||||
Reference in New Issue
Block a user