4 test_description='server pre-receive ticket enforcer via shim'
8 test_expect_success 'setup' '
11 git commit -m "setup" &&
12 git clone ./. server &&
13 rm -fr server/.git/hooks &&
14 git remote add origin ./server &&
15 git config --add branch.master.remote origin &&
16 git config --add branch.master.merge refs/heads/master
20 install_server_hook 'pre-receive-ticket' 'pre-receive'
22 test_expect_success 'reject new branch with bad message' '
23 git checkout -b topic1 master &&
25 git commit -a -m "$test_name" &&
26 head=$(git rev-parse HEAD)
27 ! git push origin topic1 >push.out 2>push.err &&
28 cat push.err | grep "Commit $head does not reference a ticket"
31 # the last test has a dirty commit message, so ammend it with a good message
32 test_expect_success 'accept new branch with re' '
33 git checkout -b topic2 master &&
35 git commit --amend -m "$test_name re #3222" &&
36 git push origin topic2
39 test_expect_success 'reject new branch with bad message in second of three' '
40 git checkout -b topic3 master &&
41 echo "$test_name first" >a &&
42 git commit -a -m "$test_name first re #3222" &&
45 echo "$test_name second" >a &&
46 git commit -a -m "$test_name second" &&
47 head=$(git rev-parse HEAD) &&
49 echo "$test_name third" >a &&
50 git commit -a -m "$test_name third re #3222" &&
52 ! git push origin topic3 >push.out 2>push.err &&
53 cat push.err | grep "Commit $head does not reference a ticket"
56 test_expect_success 'accept new branch with re in all of three' '
57 git checkout -b topic4 master &&
58 echo "$test_name first" >a &&
59 git commit -a -m "$test_name first re #3222" &&
62 echo "$test_name second" >a &&
63 git commit -a -m "$test_name second re #3222" &&
64 head=$(git rev-parse HEAD) &&
66 echo "$test_name third" >a &&
67 git commit -a -m "$test_name third re #3222" &&
69 git push origin topic4