Skip to content

Commit

Permalink
tools: Don't lint in pre-commit hook if no files changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
robot-dreams authored and timabbott committed Mar 19, 2017
1 parent 5ada385 commit ac488fd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tools/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@
# contains your provisioned Zulip development environment, the linter
# will automatically be run through `vagrant ssh`.

changed_files=$(git diff --cached --name-only --diff-filter=ACM)
if [ -z "$changed_files" ]; then
echo "No changed files to lint."
exit 0
fi

if [ -z "$VIRTUAL_ENV" ] && `which vagrant > /dev/null` && [ -e .vagrant ]; then
vcmd='/srv/zulip/tools/lint-all --pep8 --force $(cd /srv/zulip && git diff --cached --name-only --diff-filter=ACM) || true'
vcmd="/srv/zulip/tools/lint-all --pep8 --force $changed_files || true"
echo "Running lint-all using vagrant..."
vagrant ssh -c "$vcmd"
else
./tools/lint-all --pep8 --force $(git diff --cached --name-only --diff-filter=ACM) || true
./tools/lint-all --pep8 --force $changed_files || true
fi
exit 0

0 comments on commit ac488fd

Please sign in to comment.