Sfoglia il codice sorgente

Fixed git commit hook

Jeremy Stretch 6 anni fa
parent
commit
f2076c9572
1 ha cambiato i file con 16 aggiunte e 0 eliminazioni
  1. 16 0
      scripts/git-hooks/pre-commit

+ 16 - 0
scripts/git-hooks/pre-commit

@@ -9,8 +9,24 @@
 
 exec 1>&2
 
+EXIT=0
+RED='\033[0;31m'
+NOCOLOR='\033[0m'
+
 echo "Validating PEP8 compliance..."
 pycodestyle --ignore=W504,E501 netbox/
+if [ $? != 0 ]; then
+	EXIT=1
+fi
 
 echo "Checking for missing migrations..."
 python netbox/manage.py makemigrations --dry-run --check
+if [ $? != 0 ]; then
+	EXIT=1
+fi
+
+if [ $EXIT != 0 ]; then
+  printf "${RED}COMMIT FAILED${NOCOLOR}\n"
+fi
+
+exit $EXIT