Merge "tox: make it possible to run pep8 on current patch only"

This commit is contained in:
Jenkins 2015-07-27 12:06:26 +00:00 committed by Gerrit Code Review
commit 0b1b177a82
2 changed files with 21 additions and 1 deletions

20
tools/flake8wrap.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/sh
#
# A simple wrapper around flake8 which makes it possible
# to ask it to only verify files changed in the current
# git HEAD patch.
#
# Intended to be invoked via tox:
#
# tox -epep8 -- -HEAD
#
if test "x$1" = "x-HEAD" ; then
shift
files=$(git diff --name-only HEAD~1 | tr '\n' ' ')
echo "Running flake8 on ${files}"
diff -u --from-file /dev/null ${files} | flake8 --diff "$@"
else
echo "Running flake8 on all files"
exec flake8 "$@"
fi

View File

@ -27,7 +27,7 @@ downloadcache = ~/cache/pip
[testenv:pep8] [testenv:pep8]
commands = commands =
flake8 {posargs} bash tools/flake8wrap.sh {posargs}
[testenv:py34] [testenv:py34]
setenv = {[testenv]setenv} setenv = {[testenv]setenv}