summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/ci/ci-pending.sh25
1 files changed, 12 insertions, 13 deletions
diff --git a/apps/ci/ci-pending.sh b/apps/ci/ci-pending.sh
index fa3f798d4b..87858b33c6 100644
--- a/apps/ci/ci-pending.sh
+++ b/apps/ci/ci-pending.sh
@@ -4,17 +4,16 @@ set -e
echo "Pending SQL check script:"
echo
-for i in `find data/sql/updates/pending* -name "*.sql" -type f`; do
- if $(cat "$i"|sed "s/'.*'\(.*\)/\1/g"|grep -q -i -E "(PROCEDURE|FUNCTION)"); then
- echo "> PROCEDURE check - Failed"
- exit 1
- else
- echo "> PROCEDURE check - OK"
- fi
-done
-
-for i in `find data/sql/updates/pending* -name "*.sql" -type f`; do
- if [[ $(cat "$i"|sed 's/ --[^--]*$//'|tr -d '\n'|tr -d " "|tail -c 1) != ";" ]]; then
+# 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
@@ -22,8 +21,8 @@ for i in `find data/sql/updates/pending* -name "*.sql" -type f`; do
fi
done
-for i in `find data/sql/updates/pending* -name "*sql" -type f`; do
- if $(cat "$i"|sed "s/'.*'\(.*\)/\1/g"|grep -q -i -E "broadcast_text"); then
+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."