forked from zulip/zulip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pre-commit
executable file
·28 lines (24 loc) · 967 Bytes
/
pre-commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash
# This hook runs the Zulip code linter ./tools/lint 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`.
changed_files=()
while read -r -d '' f; do
changed_files+=("$f")
done < <(git diff -z --cached --name-only --diff-filter=ACM)
if [ ${#changed_files} -eq 0 ]; then
echo "No changed files to lint."
exit 0
fi
if [ -z "$VIRTUAL_ENV" ] && command -v vagrant > /dev/null && [ -e .vagrant ]; then
vcmd="/srv/zulip/tools/lint --skip=gitlint --force $(printf '%q ' "${changed_files[@]}") || true"
echo "Running lint using vagrant..."
vagrant ssh -c "$vcmd"
else
./tools/lint --skip=gitlint --force "${changed_files[@]}" || true
fi
exit 0