forked from ipfs-shipyard/py-ipfs-http-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre-commit
executable file
·53 lines (44 loc) · 1.03 KB
/
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/sh
set -eu
PROGNAME="${0}"
usage()
{
echo "Usage: ${PROGNAME} [--install]"
echo
echo " --install Install the pre-commit hook"
echo " -h, --help Display this help and exit"
echo
echo "Without any options the pre-commit checks are run."
}
if [ $# -gt 0 ];
then
case "${1}" in
"--install")
top_dir="$(git rev-parse --show-toplevel)"
git_dir="$(git rev-parse --git-dir)"
if [ -f "${git_dir}/hooks/pre-commit" ];
then
echo "ERROR: found existing pre-commit hook; " \
"cowardly giving up." >&2
exit 1
fi
echo " • Installing pre-commit hook to ${git_dir}/hooks"
ln -s "${top_dir}/tools/pre-commit" "${git_dir}/hooks/pre-commit"
echo " • Enabling GIT hook Unicode support"
git config --local --type=bool hooks.allownonascii true
exit
;;
"-h"|"--help")
usage
exit 0
;;
*)
echo "${PROGNAME}: Unknown option “${1}”" >&2
echo >&2
usage >&2
exit 2
;;
esac
fi
# Run code style and type tests before accepting a commit
tox -e styleck -e typeck