From d98c19ca983157a99637f8b02fc95d94fe6dc9e5 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 7 Feb 2017 13:19:43 -0800 Subject: [PATCH] lint: Include pep8 checks in pre-commit hook. --- tools/lint-all | 2 ++ tools/pre-commit | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/lint-all b/tools/lint-all index f5bd65696d..7029148098 100755 --- a/tools/lint-all +++ b/tools/lint-all @@ -136,6 +136,8 @@ def check_pep8(files): # Fixing these would probably reduce readability in most cases. 'E731', ] + if len(files) == 0: + return False pep8 = subprocess.Popen( ['pycodestyle'] + files + ['--ignore={rules}'.format(rules=','.join(ignored_rules))], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) diff --git a/tools/pre-commit b/tools/pre-commit index cf59100bf6..617b6294cb 100755 --- a/tools/pre-commit +++ b/tools/pre-commit @@ -10,10 +10,10 @@ # will automatically be run through `vagrant ssh`. if [ -z "$VIRTUAL_ENV" ] && `which vagrant > /dev/null` && [ -e .vagrant ]; then - vcmd='/srv/zulip/tools/lint-all --force $(cd /srv/zulip && git diff --cached --name-only --diff-filter=ACM) || true' + vcmd='/srv/zulip/tools/lint-all --pep8 --force $(cd /srv/zulip && git diff --cached --name-only --diff-filter=ACM) || true' echo "Running lint-all using vagrant..." vagrant ssh -c "$vcmd" else - ./tools/lint-all --force $(git diff --cached --name-only --diff-filter=ACM) || true + ./tools/lint-all --pep8 --force $(git diff --cached --name-only --diff-filter=ACM) || true fi exit 0