diff options
author | Mike Delago <32778141+michaeldelago@users.noreply.github.com> | 2023-08-06 05:43:51 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-06 11:43:51 +0200 |
commit | e7b3f5e78aee38bdcf9dc7387b854a2072b49173 (patch) | |
tree | d50b455b875ffb99a51e57e7bc548c7a5e836d9c /apps | |
parent | 9eadbdf6119b25a6953f93b0e357ae607837f21b (diff) |
chore(CI): fix `ci-pending.sh` script for linting SQL (#16913)
* fix Checks for pending sql
* remove strings in general
* Update apps/ci/ci-pending.sh
---------
Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/ci/ci-pending.sh | 25 |
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." |