install_hooks.sh 836 Bytes
Newer Older
1
2
#!/bin/sh

3
ROOT=$(git rev-parse --show-toplevel)
4
HOOKSDIR=$ROOT/tools/git_hooks/release
5
HOOKS=pre-commit
6
GITHOOKSDIR=$ROOT/.git/hooks
7

8
9
10
11
while test $# -ne 0; do
    if test $1 = "-d" || test $1 = "--debug"; then
	HOOKSDIR=$ROOT/tools/git_hooks/debug
    fi
12
13
14
15
16
17
18
19
    if test $1 = "-u" || test $1 = "--uninstall"; then
	echo -n "Uninstalling git hooks from local repository..."
	for i in $HOOKS; do
	    rm -f $GITHOOKSDIR/$i
	done
	echo "done."
	exit 0
    fi
20
21
22
    shift
done

23
24
25
26
27
28
29
30
31
32
33
echo "Installing git hooks to local repository..."
for i in $HOOKS; do
    echo -n "Installing $HOOKSDIR/$i..."
    if test -e $GITHOOKSDIR/$i && test ! -h $GITHOOKSDIR/$i; then
	echo -n "\nWarning: $GITHOOKSDIR/$i already exists and is not a symbolic"
	echo " link. $HOOKSDIR/$i not installed."
    else
	ln -sf $HOOKSDIR/$i $GITHOOKSDIR/$i
	echo "done."
    fi
done