Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # An example hook script to verify what is about to be committed.
  4. # Called by "git commit" with no arguments. The hook should
  5. # exit with non-zero status after issuing an appropriate message if
  6. # it wants to stop the commit.
  7.  
  8. ######################
  9. # check non-ASCII
  10. ######################
  11.  
  12. if git rev-parse --verify HEAD >/dev/null 2>&1
  13. then
  14. against=HEAD
  15. else
  16. # Initial commit: diff against an empty tree object
  17. against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
  18. fi
  19.  
  20. # If you want to allow non-ASCII filenames set this variable to true.
  21. allownonascii=$(git config --bool hooks.allownonascii)
  22.  
  23. # Redirect output to stderr.
  24. exec 1>&2
  25.  
  26. # Cross platform projects tend to avoid non-ASCII filenames; prevent
  27. # them from being added to the repository. We exploit the fact that the
  28. # printable range starts at the space character and ends with tilde.
  29. if [ "$allownonascii" != "true" ] &&
  30. # Note that the use of brackets around a tr range is ok here, (it's
  31. # even required, for portability to Solaris 10's /usr/bin/tr), since
  32. # the square bracket bytes happen to fall in the designated range.
  33. test $(git diff --cached --name-only --diff-filter=A -z $against |
  34. LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
  35. then
  36. cat <<\EOF
  37. Error: Attempt to add a non-ASCII file name.
  38.  
  39. Commit ignored...
  40. EOF
  41. exit 1
  42. fi
  43.  
  44. ######################
  45. # check PEP8
  46. ######################
  47. # check pep8's checker exists
  48. if ! type "pep8" > /dev/null; then
  49. cat <<\EOF
  50. Error: Does not exists pep8's checker
  51.  
  52. Do:
  53.  
  54. sudo pip install pep8
  55.  
  56. Commit ignored...
  57. EOF
  58. exit 1
  59. fi
  60. # check pep8
  61. if test $(pep8 --first src/ | wc -c) != 0
  62. then
  63. cat <<\EOF
  64. Error: Broken PEP8 standard
  65. PEP8 violations list:
  66.  
  67. EOF
  68. pep8 --first src
  69. cat <<\EOF
  70.  
  71.  
  72. To check standart:
  73.  
  74. pep8 --first src/
  75.  
  76. Commit ignored...
  77. EOF
  78. exit 1
  79. fi
  80.  
  81.  
  82.  
  83. # If there are whitespace errors, print the offending file names and fail.
  84. exec git diff-index --check --cached $against --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement