precommit.sh 351 B

123456789101112131415161718192021
  1. #!/bin/bash
  2. function abort(){
  3. echo "Your commit not fit PaddlePaddle code style" 1>&2
  4. echo "Please use pre-commit scripts to auto-format your code" 1>&2
  5. exit 1
  6. }
  7. trap 'abort' 0
  8. set -e
  9. cd `dirname $0`
  10. cd ..
  11. export PATH=/usr/bin:$PATH
  12. pre-commit install
  13. if ! pre-commit run -a ; then
  14. ls -lh
  15. git diff --exit-code
  16. exit 1
  17. fi
  18. trap : 0