diff options
author | Zhenguo Niu <niuzhenguo@huawei.com> | 2015-12-22 15:46:46 +0800 |
---|---|---|
committer | Zhenguo Niu <niuzhenguo@huawei.com> | 2016-01-05 09:55:48 +0800 |
commit | 29b37065d75e9a95d578fc626fc9eb9c3ae0ba39 (patch) | |
tree | 88e2426e97f0e9cb40e189abcac6e7448faf07cb /tools | |
parent | 0371f6678d164292eb040d74a37e87eb361f4d30 (diff) | |
download | ironic-29b37065d75e9a95d578fc626fc9eb9c3ae0ba39.tar.gz |
tox: make it possible to run pep8 on current patch only
This makes tox use a simple wrapper around flake8 like
Nova, which can be told to restrict the check to only
files changed in the current command. This can be invoked
in a simple manner with 'tox -epep8 -- -HEAD'. Since most
commits only touch a handful of files, this will usually
be far faster than checking all source files.
To check an entire branch for bisectability it can be
automated via
git rebase -i master -x 'tox -epep8 -- -HEAD'
Change-Id: I75b1cfe3198b1217f8b25877714a4af47ae7069f
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/flake8wrap.sh | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/flake8wrap.sh b/tools/flake8wrap.sh new file mode 100755 index 000000000..531b407d6 --- /dev/null +++ b/tools/flake8wrap.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# +# 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 |