Files
zulip/tools/pre-commit
Christie Koehler 7f48b3c137 tools: Update pre-commit hook so it works with vagrant dev setup.
Details:

Previously this hook required that you either be inside the vagrant
Zulip dev virtual machine when you ran git commit or that you had setup
your Zulip dev environment manually.

Now the script runs the linter via vagrant ssh if the following
conditions are met:

- VIRTUAL_ENV is not set
- vagrant is installed and a .vagrant directory exists in the repo

Otherwise the linter is run as it was before.

[tweaked to fix a few style things by tabbott]
2016-08-25 15:19:40 -07:00

20 lines
766 B
Bash
Executable File

#!/bin/bash
# This hook runs the Zulip code linter ./tools/lint-all and returns true
# regardless of linter results so that your commit may continue.
# Messages from the linter will be printed out to the screen.
#
# If you are running this one machine hosting a Vagrant guest that
# contains your provisioned Zulip development environment, the linter
# will automatically be run through `vagrant ssh`.
if [ -z "$VIRTUAL_ENV" ] && `which vagrant > /dev/null` && [ -e .vagrant ]; then
vcmd='/srv/zulip/tools/lint-all $(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 $(git diff --cached --name-only --diff-filter=ACM) || true
fi
exit 0