Skip to content
Snippets Groups Projects
Commit 226af542 authored by Eoin Clerkin's avatar Eoin Clerkin
Browse files

Allow file deletion

Fix ascii checker to ignore deleted or empty files.
parent 8324968b
No related branches found
No related tags found
1 merge request!2073Allow file deletion
Pipeline #33625 failed
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
# SPDX-License-Identifier: GPL-3.0-only # SPDX-License-Identifier: GPL-3.0-only
# First commited by Florian Uhlig # First commited by Florian Uhlig
if [[ $# -eq 1 ]]; then if [[ $# -eq 1 ]]; then
UPSTREAM=$1 UPSTREAM=$1
else else
...@@ -23,24 +22,26 @@ BASE_COMMIT=$UPSTREAM/master ...@@ -23,24 +22,26 @@ BASE_COMMIT=$UPSTREAM/master
# check only source code files # check only source code files
CHANGED_FILES=$(git diff --name-only $BASE_COMMIT | grep -E '.*\.(h|hpp|c|C|cpp|cxx|tpl)$' | grep -viE '.*LinkDef.h$') CHANGED_FILES=$(git diff --name-only $BASE_COMMIT | grep -E '.*\.(h|hpp|c|C|cpp|cxx|tpl)$' | grep -viE '.*LinkDef.h$')
EXIT_CODE=0;
for file in $CHANGED_FILES; do for file in $CHANGED_FILES; do
# find all source code files which are non ASCII ones
result=$(file $file | grep -v ASCII)
if [[ "$result" != "" ]]; then
echo " "
echo "File $file contains non ASCII characters"
pcregrep --color='auto' -n "[\x80-\xFF]" $file
echo " "
okay=false
fi
done
if [[ "$okay" = "false" ]]; then file $file | grep -q \
echo "" -e 'ASCII text' \
echo "There are files which contain non ASCII characters" -e 'empty$' \
echo "Test failed" -e '(No such file or directory)$';
exit 1
else if [ $? -ne 0 ]; then
exit 0
fi echo "NON ASCII file detected: $file ";
if [ -x "$(command -v pcregrep)" ]; then
pcregrep --color='auto' -n "[\x80-\xFF]" $file;
else
grep --color='auto' -P -n "[\x80-\xFF]" $file;
fi
let EXIT_CODE++;
fi
done
exit ${EXIT_CODE}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment