Enable DOS/Windows line-ending checks at patch-level
Change-Id: Iee7ba34e5228cb890606be574a8fd4b6738ed416
Signed-off-by: Leonardo Sandoval <leonardo.sandoval@linaro.org>
diff --git a/script/static-checks/static-checks-coding-style-line-endings.sh b/script/static-checks/static-checks-coding-style-line-endings.sh
index ae7a6db..5442f7d 100755
--- a/script/static-checks/static-checks-coding-style-line-endings.sh
+++ b/script/static-checks/static-checks-coding-style-line-endings.sh
@@ -7,43 +7,46 @@
TEST_CASE="Line endings not valid"
+EXIT_VALUE=0
+
echo "# Check Line Endings"
-LOG_FILE=`mktemp -t common.XXXX`
+LOG_FILE=$(mktemp -t common.XXXX)
-# For all the source and doc files
-# We only return the files that contain CRLF
-find "." -\( \
- -name '*.S' -or \
- -name '*.c' -or \
- -name '*.h' -or \
- -name '*.i' -or \
- -name '*.dts' -or \
- -name '*.dtsi' -or \
- -name '*.rst' -or \
- -name 'Makefile' -or \
- -name '*.mk' \
--\) -exec grep --files-with-matches $'\r$' {} \; &> "$LOG_FILE"
+if [[ "$2" == "patch" ]]; then
+ cd "$1"
+ parent=$(git merge-base HEAD master | head -1)
+ git diff ${parent}..HEAD --no-ext-diff --unified=0 --exit-code -a --no-prefix | grep -E "^\+" | \
+ grep --files-with-matches $'\r$' &> "$LOG_FILE"
+else
+ # For all the source and doc files
+ # We only return the files that contain CRLF
+ find "." -\( \
+ -name '*.S' -or \
+ -name '*.c' -or \
+ -name '*.h' -or \
+ -name '*.i' -or \
+ -name '*.dts' -or \
+ -name '*.dtsi' -or \
+ -name '*.rst' -or \
+ -name 'Makefile' -or \
+ -name '*.mk' \
+ -\) -exec grep --files-with-matches $'\r$' {} \; &> "$LOG_FILE"
+fi
if [[ -s "$LOG_FILE" ]]; then
- EXIT_VALUE=1
-else
- EXIT_VALUE=0
+ EXIT_VALUE=1
fi
-echo >> "$LOG_TEST_FILENAME"
-echo "****** $TEST_CASE ******" >> "$LOG_TEST_FILENAME"
-echo >> "$LOG_TEST_FILENAME"
-if [[ "$EXIT_VALUE" == 0 ]]; then
- echo "Result : SUCCESS" >> "$LOG_TEST_FILENAME"
-else
- echo "Result : FAILURE" >> "$LOG_TEST_FILENAME"
- echo >> "$LOG_TEST_FILENAME"
- cat "$LOG_FILE" >> "$LOG_TEST_FILENAME"
-fi
-echo >> "$LOG_TEST_FILENAME"
+{ echo; echo "****** $TEST_CASE ******"; echo; } >> "$LOG_TEST_FILENAME"
+
+{ if [[ "$EXIT_VALUE" == 0 ]]; then \
+ echo "Result : SUCCESS"; \
+ else \
+ echo "Result : FAILURE"; echo; cat "$LOG_FILE"; \
+ fi \
+} | tee -a "$LOG_TEST_FILENAME"
rm "$LOG_FILE"
exit "$EXIT_VALUE"
-