Commit c1d0e3c6 authored by Jerome Berthier's avatar Jerome Berthier Committed by Vincent A

tools/pyflakes.sh: allow to override PYFILES from environment variable

Useful when using with a pre-push hook, it is useless to run flakes
on the whole code base every time you push.

Example of pre-push hook using this feature:

ref=$(git rev-list --boundary HEAD...master | grep "^-" | cut -c2-)
PYFILES="$(git diff ${ref} --name-only | grep -E "*.py$" | xargs)" $PWD/tools/pyflakes.sh
if [ "$?" -ne "0" ]; then
    echo >&2 "Flakes error"
    exit 1
fi
parent 47780392
......@@ -7,8 +7,13 @@ cd $(dirname $0)/..
MODULE_FILES=$(git ls-files modules|grep '\.py$')
PYFILES=$(git ls-files | grep '^scripts\|\.py$'|grep -v boilerplate_data|grep -v stable_backport_data|grep -v '^modules'|grep -v '^contrib')
PYFILES="$PYFILES $MODULE_FILES"
# Takes PYFILES from env, if empty use all git tracked files
: ${PYFILES:=}
if [ -z "${PYFILES}" ]; then
PYFILES="$(git ls-files | grep '^scripts\|\.py$'|grep -v boilerplate_data|grep -v stable_backport_data|grep -v '^modules'|grep -v '^contrib')"
PYFILES="$PYFILES $MODULE_FILES"
fi
grep -n '[[:space:]]$' ${PYFILES} && echo 'Error: tabs or trailing whitespace found, remove them' && err=4
grep -Fn '.setlocale' ${PYFILES} && echo 'Error: do not use setlocale' && err=5
grep -Fn '__future__ import with_statement' ${PYFILES} && echo 'Error: with_statement useless as we do not support Python 2.5' && err=6
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment