3 # Simple pre-commit hook to check that there are no errors in the fdroidserver
6 # Redirect output to stderr.
9 PY_FILES="fdroid makebuildserver setup.py examples/*.py buildserver/*.py fdroidserver/*.py tests/*.TestCase"
10 SH_FILES="hooks/pre-commit"
11 BASH_FILES="fd-commit jenkins-build docs/update.sh completion/bash-completion"
12 RB_FILES="buildserver/cookbooks/*/recipes/*.rb"
14 # In the default configuration, the checks E123, E133, E226, E241 and E242 are
15 # ignored because they are not rules unanimously accepted
16 # On top of those, we ignore:
17 # * E501: line too long (82 > 79 characters)
18 # - Recommended for readability but not enforced
19 # - Some lines are awkward to wrap around a char limit
20 # * W503: line break before binary operator
24 PEP8_IGNORE="E123,E133,E226,E241,E242,E501,W503"
32 command -v $1 1>/dev/null
35 if cmd_exists pyflakes-python2; then
36 PYFLAKES=pyflakes-python2
37 elif cmd_exists pyflakes; then
40 err "pyflakes is not installed!"
43 if cmd_exists pep8-python2; then
45 elif cmd_exists pep8; then
48 err "pep8 is not installed!"
51 if ! $PYFLAKES $PY_FILES; then
52 err "pyflakes tests failed!"
55 if ! $PEP8 --ignore=$PEP8_IGNORE $PY_FILES; then
56 err "pep8 tests failed!"
60 for f in $SH_FILES; do
62 err "dash tests failed!"
66 for f in $BASH_FILES; do
68 err "bash tests failed!"
72 for f in $RB_FILES; do
73 if ! ruby -c $f 1>/dev/null; then
74 err "ruby tests failed!"