pre-commit 486 B

12345678910111213141516171819202122232425
  1. #!/bin/sh
  2. FILES=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php`
  3. # Determine if a file list is passed
  4. if [ "$#" -eq 1 ]
  5. then
  6. oIFS=$IFS
  7. IFS='
  8. '
  9. SFILES="$1"
  10. IFS=$oIFS
  11. fi
  12. SFILES=${SFILES:-$FILES}
  13. if [ "$FILES" != "" ]
  14. then
  15. echo "Running PHPCS"
  16. ./vendor/bin/phpcs --standard=vendor/cakephp/cakephp-codesniffer/CakePHP $SFILES
  17. if [ $? != 0 ]
  18. then
  19. echo "PHPCS Errors found; commit aborted."
  20. exit 1
  21. fi
  22. fi
  23. exit $?