chiark / gitweb /
Add config.buildserver.py to the pre-commit hook
[fdroidserver.git] / hooks / pre-commit
1 #!/bin/sh
2 #
3 # Simple pre-commit hook to check that there are no errors in the fdroid
4 # metadata files.
5
6 # Redirect output to stderr.
7 exec 1>&2
8
9 FILES="fdroid makebuildserver examples/*.py buildserver/*.py fdroidserver/*.py"
10
11 cmd_exists() {
12         command -v $1 1>/dev/null
13 }
14
15 # For systems that switched to python3, first check for the python2 versions
16 if cmd_exists pyflakes-python2; then
17         PYFLAKES=pyflakes-python2
18 elif cmd_exists pyflakes; then
19         PYFLAKES=pyflakes
20 else
21         echo "pyflakes is not installed!"
22 fi
23
24 if cmd_exists pep8-python2; then
25         PEP8=pep8-python2
26 elif cmd_exists pep8; then
27         PEP8=pep8
28 else
29         echo "pep8 is not installed!"
30 fi
31
32 # If there are python errors or warnings, print them and fail.
33 [ -n $PYFLAKES ] && $PYFLAKES $FILES
34 [ -n $PEP8 ] && $PEP8 --ignore=E123,E501 $FILES