mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 06:38:10 +00:00

This script checks .html, .css, .js, .cpp, .h, .gml and .sh files. It also makes sure that there are no black lines at the end of the files checked.
42 lines
1.1 KiB
Bash
Executable file
42 lines
1.1 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
|
|
cd "$script_path/.." || exit 1
|
|
|
|
MISSING_NEWLINE_AT_EOF_ERRORS=()
|
|
MORE_THAN_ONE_NEWLINE_AT_EOF_ERRORS=()
|
|
|
|
while IFS= read -r f; do
|
|
[ -s "$f" ] || continue
|
|
|
|
if [ "$(tail -n 1 "$f" | wc -l)" != 1 ]; then
|
|
MISSING_NEWLINE_AT_EOF_ERRORS+=( "$f" )
|
|
elif [[ "$(tail -n 1 "$f")" =~ ^[[:space:]]*$ ]]; then
|
|
MORE_THAN_ONE_NEWLINE_AT_EOF_ERRORS+=( "$f" )
|
|
fi
|
|
done < <(git ls-files -- \
|
|
'*.cpp' \
|
|
'*.h' \
|
|
'*.gml' \
|
|
'*.html' \
|
|
'*.js' \
|
|
'*.css' \
|
|
'*.sh' \
|
|
':!:Base' \
|
|
':!:Kernel/FileSystem/ext2_fs.h' \
|
|
':!:Libraries/LibC/getopt.cpp' \
|
|
':!:Libraries/LibCore/puff.h' \
|
|
':!:Libraries/LibCore/puff.cpp' \
|
|
':!:Libraries/LibELF/exec_elf.h' \
|
|
)
|
|
|
|
exit_status=0
|
|
if (( ${#MISSING_NEWLINE_AT_EOF_ERRORS[@]} )); then
|
|
echo "Files with no newline at the end: ${MISSING_NEWLINE_AT_EOF_ERRORS[*]}"
|
|
exit_status=1
|
|
fi
|
|
if (( ${#MORE_THAN_ONE_NEWLINE_AT_EOF_ERRORS[@]} )); then
|
|
echo "Files that have blank lines at the end: ${MORE_THAN_ONE_NEWLINE_AT_EOF_ERRORS[*]}"
|
|
exit_status=1
|
|
fi
|
|
exit "$exit_status"
|