From 51ae429040410e23fdef94a4b901dac342f3af57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Koci=C3=A1n?= Date: Sun, 18 Sep 2016 23:16:44 +0200 Subject: [PATCH] =?UTF-8?q?git=20hooks:=20lok=C3=A1ln=C3=AD=20flake8=20a?= =?UTF-8?q?=20jen=20kdy=C5=BE=20jsou=20zm=C4=9Bny?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _git_hooks/pre-commit | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/_git_hooks/pre-commit b/_git_hooks/pre-commit index bdea5060..3ba59e0a 100755 --- a/_git_hooks/pre-commit +++ b/_git_hooks/pre-commit @@ -3,4 +3,20 @@ # Git hook script to verify what is about to be committed. # Checks that the changes don't introduce new flake8 errors. -git diff --unified=1 --cached HEAD -- '*py' | flake8 --diff +TMPDIFF=`tempfile` +FLAKE8="`git rev-parse --show-toplevel`/bin/flake8" + +status=0 + +git diff --unified=1 --cached HEAD -- '*py' > $TMPDIFF + +# only do the check when there are some changes to be commited +# otherwise flake8 would hang waiting for input +if [ -s $TMPDIFF ] ; then + cat $TMPDIFF | $FLAKE8 --diff + status=$? +fi + +rm -f $TMPDIFF + +exit $status