3 test_description='server pre-receive ticket enforcer via shim'
7 test_expect_success 'setup' '
10 git commit -m "setup" &&
11 git clone ./. server &&
12 rm -fr server/.git/hooks &&
13 git remote add origin ./server &&
14 git config --add branch.master.remote origin &&
15 git config --add branch.master.merge refs/heads/master
19 install_server_hook 'pre-receive-ticket' 'pre-receive'
21 test_expect_success 'reject new branch with bad message' '
22 git checkout -b topic1 master &&
24 git commit -a -m "$test_name" &&
25 head=$(git rev-parse HEAD)
26 ! git push origin topic1 >push.out 2>push.err &&
27 cat push.err | grep "Commit $head does not reference a ticket"
30 # the last test has a dirty commit message, so ammend it with a good message
31 test_expect_success 'accept new branch with re' '
32 git checkout -b topic2 master &&
34 git commit --amend -m "$test_name re #3222" &&
35 git push origin topic2
38 test_expect_success 'reject new branch with bad message in second of three' '
39 git checkout -b topic3 master &&
40 echo "$test_name first" >a &&
41 git commit -a -m "$test_name first re #3222" &&
44 echo "$test_name second" >a &&
45 git commit -a -m "$test_name second" &&
46 head=$(git rev-parse HEAD) &&
48 echo "$test_name third" >a &&
49 git commit -a -m "$test_name third re #3222" &&
51 ! git push origin topic3 >push.out 2>push.err &&
52 cat push.err | grep "Commit $head does not reference a ticket"
55 test_expect_success 'accept new branch with re in all of three' '
56 git checkout -b topic4 master &&
57 echo "$test_name first" >a &&
58 git commit -a -m "$test_name first re #3222" &&
61 echo "$test_name second" >a &&
62 git commit -a -m "$test_name second re #3222" &&
63 head=$(git rev-parse HEAD) &&
65 echo "$test_name third" >a &&
66 git commit -a -m "$test_name third re #3222" &&
68 git push origin topic4