blob: e5a2d201fd965d1ff886ebef8dcfed793495e7bd (
plain)
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
29
30
31
|
#!/bin/bash
# copy (DO NOT SYMLINK) this file to .git/hooks/pre-commit
# to check style on all modified files before allowing the commit to complete
#
# DO NOT SYMLINK
# DO NOT SYMLINK
# DO NOT SYMLINK (why? security risk)
check_errors() {
errors="$("$@")"
if [ "$?" != "0" ]; then
echo "$errors"
exit 1
fi
}
cd $(dirname "$0")/../..
check_errors git stash --keep-index
errors="$(git diff --cached | bin/style-check 2>&1)"
status=$?
if [ "$status" != "0" ]; then
echo "$errors"
fi
check_errors git stash pop
exit $status
|