refactor(CI/Codestyle): Move the SQL check to python (#21002)

This commit is contained in:
Kitzunu
2024-12-22 16:50:32 +01:00
committed by GitHub
parent cbdab03623
commit d5fac96a20
5 changed files with 148 additions and 39 deletions

View File

@@ -1,36 +0,0 @@
#!/bin/bash
set -e
echo "Pending SQL check script:"
echo
# We want to ensure the end of file has a semicolon and doesn't have extra
# newlines
find data/sql/updates/pending* -name "*.sql" -type f | while read -r file; do
# The first sed script collapses all strings into an empty string. The
# contents of strings aren't necessary for this check and its still valid
# sql.
#
# The second rule removes sql comments.
ERR_AT_EOF="$(sed -e "s/'.*'/''/g" -e 's/ --([^-])*$//' "$file" | tr -d '\n ' | tail -c 1)"
if [[ "$ERR_AT_EOF" != ";" ]]; then
echo "Missing Semicolon (;) or multiple newlines at the end of the file."
exit 1
else
echo "> Semicolon check - OK"
fi
done
find data/sql/updates/pending* -name "*.sql" -type f | while read -r file; do
if sed "s/'.*'\(.*\)/\1/g" "$file" | grep -q -i -E "broadcast_text"; then
echo "> broadcast_text check - Failed"
echo " - DON'T EDIT broadcast_text TABLE UNLESS YOU KNOW WHAT YOU ARE DOING!"
echo " - This error can safely be ignored if the changes are approved to be sniffed."
exit 1
else
echo "> broadcast_text check - OK"
fi
done
echo
echo "Everything looks good"