pre-commit 582 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/sh
  2. # Create a link to this file at .git/hooks/pre-commit to
  3. # force PEP8 validation prior to committing
  4. #
  5. # Ignored violations:
  6. #
  7. # W504: Line break after binary operator
  8. # E501: Line too long
  9. exec 1>&2
  10. EXIT=0
  11. RED='\033[0;31m'
  12. NOCOLOR='\033[0m'
  13. echo "Validating PEP8 compliance..."
  14. pycodestyle --ignore=W504,E501 netbox/
  15. if [ $? != 0 ]; then
  16. EXIT=1
  17. fi
  18. echo "Checking for missing migrations..."
  19. python netbox/manage.py makemigrations --dry-run --check
  20. if [ $? != 0 ]; then
  21. EXIT=1
  22. fi
  23. if [ $EXIT != 0 ]; then
  24. printf "${RED}COMMIT FAILED${NOCOLOR}\n"
  25. fi
  26. exit $EXIT