From: Daniel Martí Date: Thu, 14 Jan 2016 23:19:11 +0000 (+0100) Subject: Fix detection of pyflakes3 found in Debian X-Git-Tag: 0.7.0~86^2~5 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=84568c15a67f54cecdbdd5f19573abbc3e9016e0;p=fdroidserver.git Fix detection of pyflakes3 found in Debian --- diff --git a/hooks/pre-commit b/hooks/pre-commit index 53479051..f0e4d657 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -70,22 +70,21 @@ cmd_exists() { command -v $1 1>/dev/null } -if cmd_exists pyflakes-python3; then - PYFLAKES=pyflakes-python3 -elif cmd_exists pyflakes; then - PYFLAKES=pyflakes -else - PYFLAKES=echo - warn "pyflakes is not installed, using dummy placeholder!" -fi +find_command() { + local name=$1 + for suff in "3" "-python3" ""; do + cmd=${1}${suff} + if cmd_exists $cmd; then + echo -n $cmd + return 0 + fi + done + warn "$1 is not installed, using dummy placeholder!" + echo -n echo +} -if cmd_exists pep8-python3; then - PEP8=pep8-python3 -elif cmd_exists pep8; then - PEP8=pep8 -else - err "pep8 is not installed!" -fi +PYFLAKES=$(find_command pyflakes) +PEP8=$(find_command pep8) if [ "$PY_FILES $PY_TEST_FILES" != " " ]; then if ! $PYFLAKES $PY_FILES $PY_TEST_FILES; then