summaryrefslogtreecommitdiff
path: root/misc/scripts/file_format.sh
diff options
context:
space:
mode:
Diffstat (limited to 'misc/scripts/file_format.sh')
-rwxr-xr-xmisc/scripts/file_format.sh29
1 files changed, 22 insertions, 7 deletions
diff --git a/misc/scripts/file_format.sh b/misc/scripts/file_format.sh
index c767d3f8a0..1200b96ea0 100755
--- a/misc/scripts/file_format.sh
+++ b/misc/scripts/file_format.sh
@@ -37,9 +37,11 @@ while IFS= read -rd '' f; do
continue
elif [[ "$f" == *"-so_wrap."* ]]; then
continue
+ elif [[ "$f" == *".test.txt" ]]; then
+ continue
fi
# Ensure that files are UTF-8 formatted.
- recode UTF-8 "$f" 2> /dev/null
+ isutf8 "$f" >> utf8-validation.txt 2>&1
# Ensure that files have LF line endings and do not contain a BOM.
dos2unix "$f" 2> /dev/null
# Remove trailing space characters and ensures that files end
@@ -49,15 +51,28 @@ done
diff=$(git diff --color)
-# If no diff has been generated all is OK, clean up, and exit.
-if [ -z "$diff" ] ; then
+# If no UTF-8 violations were collected and no diff has been
+# generated all is OK, clean up, and exit.
+if [ ! -s utf8-validation.txt ] && [ -z "$diff" ] ; then
printf "Files in this commit comply with the formatting rules.\n"
+ rm -f utf8-violations.txt
exit 0
fi
-# A diff has been created, notify the user, clean up, and exit.
-printf "\n*** The following differences were found between the code "
-printf "and the formatting rules:\n\n"
-echo "$diff"
+# Violations detected, notify the user, clean up, and exit.
+if [ -s utf8-validation.txt ]
+then
+ printf "\n*** The following files contain invalid UTF-8 character sequences:\n\n"
+ cat utf8-validation.txt
+ rm -f utf8-validation.txt
+fi
+
+if [ ! -z "$diff" ]
+then
+ printf "\n*** The following differences were found between the code "
+ printf "and the formatting rules:\n\n"
+ echo "$diff"
+fi
+
printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\n"
exit 1