summaryrefslogtreecommitdiff
path: root/tools/flake8wrap.sh
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2015-07-24 16:05:49 +0100
committerDaniel P. Berrange <berrange@redhat.com>2015-07-24 16:15:38 +0100
commita7471dd773d498c0ba5503d9f512ac3342a7a6e3 (patch)
treeb3c48710a49b52222b59cb33166c28e817576c74 /tools/flake8wrap.sh
parent0d696adcea400da3435382a49a632f23283242f3 (diff)
downloadnova-a7471dd773d498c0ba5503d9f512ac3342a7a6e3.tar.gz
tox: make it possible to run pep8 on current patch only
The 'tox -epep8' command takes a long time as it checks every single file in the Nova git repository (~1,400 at time of writing). This makes tox use a simple wrapper around flake8 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 1,400 source files. To check an entire branch for bisectability it can be automated via git rebase -i master -x 'tox -epep8 -- -HEAD' Change-Id: I157d1ccb883ca02402eee51fd7d6a50f86079389
Diffstat (limited to 'tools/flake8wrap.sh')
-rwxr-xr-xtools/flake8wrap.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/flake8wrap.sh b/tools/flake8wrap.sh
new file mode 100755
index 0000000000..ab3269df7f
--- /dev/null
+++ b/tools/flake8wrap.sh
@@ -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