Skip to content
Snippets Groups Projects
Commit d7be6b9c authored by Andre Maroneze's avatar Andre Maroneze
Browse files

[Dev] add script to check for end of files without newlines

parent 791ce746
No related branches found
No related tags found
No related merge requests found
...@@ -19,8 +19,10 @@ is_likely_text_file() { ...@@ -19,8 +19,10 @@ is_likely_text_file() {
declare -A exceptions declare -A exceptions
exceptions=(["VERSION"]=1 ["VERSION_CODENAME"]=1) exceptions=(["VERSION"]=1 ["VERSION_CODENAME"]=1)
errors=0
IFS='' IFS=''
cat "$1" | file -f "$1" --mime | grep '\btext' | cut -d: -f1 |
while read file while read file
do do
if [ -n "$(is_likely_text_file "$file")" ]; then if [ -n "$(is_likely_text_file "$file")" ]; then
...@@ -28,8 +30,13 @@ do ...@@ -28,8 +30,13 @@ do
if [ "$x" != "" ]; then if [ "$x" != "" ]; then
if [ ! ${exceptions["$file"]+x} ]; then if [ ! ${exceptions["$file"]+x} ]; then
echo "error: no newline at end of file: $file" echo "error: no newline at end of file: $file"
exit 1 errors=$((errors+1))
fi fi
fi fi
fi fi
done done
if [ $errors -gt 0 ]; then
echo "Found $error(s) files with errors."
exit 0
fi
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