2016-08-17 22:03:54 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-04-21 23:07:06 +02:00
|
|
|
# This hook runs the Zulip code linter ./tools/lint and returns true
|
2016-08-17 22:03:54 +02:00
|
|
|
# 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`.
|
|
|
|
|
2017-03-19 21:18:10 +01:00
|
|
|
changed_files=$(git diff --cached --name-only --diff-filter=ACM)
|
|
|
|
if [ -z "$changed_files" ]; then
|
|
|
|
echo "No changed files to lint."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2016-08-17 22:03:54 +02:00
|
|
|
if [ -z "$VIRTUAL_ENV" ] && `which vagrant > /dev/null` && [ -e .vagrant ]; then
|
2017-08-25 15:23:02 +02:00
|
|
|
vcmd="/srv/zulip/tools/lint --no-gitlint --force $changed_files || true"
|
2017-04-21 23:07:06 +02:00
|
|
|
echo "Running lint using vagrant..."
|
2016-08-17 22:03:54 +02:00
|
|
|
vagrant ssh -c "$vcmd"
|
|
|
|
else
|
2017-08-25 15:23:02 +02:00
|
|
|
./tools/lint --no-gitlint --force $changed_files || true
|
2016-08-17 22:03:54 +02:00
|
|
|
fi
|
|
|
|
exit 0
|