Dumb shell script installer for our client hooks.
[git-central.git] / install-cbas-client-hooks.sh
1 #!/bin/sh
2
3 rm .git/hooks/*
4
5 cat >.git/hooks/commit-msg <<'FOO'
6 #!/bin/sh
7
8 grep -i '\(\(re\|refs\|qa\) #[0-9]\+\)\|\(no ticket\)' "$1" > /dev/null
9
10 if [ $? -ne 0 ]
11 then
12         echo "Please reference a ticket"
13         exit 1
14 fi
15 FOO
16
17 cat >.git/hooks/post-checkout <<'FOO'
18 #!/bin/bash
19
20 # The hook is given three parameters: the ref of the previous HEAD, the ref of
21 # the new HEAD (which may or may not have changed), and a flag indicating
22 # whether the checkout was a branch checkout (changing branches, flag=1) or a
23 # file checkout (retrieving a file from the index, flag=0).
24
25 branch=$(git symbolic-ref HEAD)
26 branch=${branch/refs\/heads\//}
27
28 git config --list | grep "branch.${branch}.rebase" > /dev/null
29 if [ $? -ne 0 ] ; then
30         git config --add "branch.${branch}.rebase" true
31 fi
32 FOO
33