3 # Simple pre-commit hook to check that there are no errors in the fdroid
6 # Redirect output to stderr.
9 PY_FILES="fdroid makebuildserver setup.py examples/*.py buildserver/*.py fdroidserver/*.py"
10 SH_FILES="fd-commit jenkins-build docs/*.sh hooks/pre-commit"
11 RB_FILES="buildserver/cookbooks/*/recipes/*.rb"
19 command -v $1 1>/dev/null
22 # For systems that switched to python3, first check for the python2 versions
24 if cmd_exists pyflakes-python2; then
25 PYFLAKES=pyflakes-python2
26 elif cmd_exists pyflakes; then
29 err "pyflakes is not installed!"
32 if cmd_exists pep8-python2; then
34 elif cmd_exists pep8; then
37 err "pep8 is not installed!"
40 # If there are python errors or warnings, print them and fail.
42 if ! $PYFLAKES $PY_FILES; then
43 err "pyflakes tests failed!"
46 if ! $PEP8 --ignore=E123,E501 $PY_FILES; then
47 err "pep8 tests failed!"
51 # check the syntax of included shell scripts with bash -n
53 for f in $SH_FILES; do
55 err "bash tests failed!"
59 # check the syntax of included ruby scripts with ruby -c
61 for f in $RB_FILES; do
62 if ! ruby -c $f 1>/dev/null; then
63 err "ruby tests failed!"