3 test_description='server update trac ticket enforcer'
7 test_expect_success 'setup' '
8 echo This is a test. >a &&
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
18 # setup the update hook
19 install_server_hook 'update-ensure-ticket-reference' 'update'
21 test_expect_success 'reject with bad message' '
23 git commit -a -m "$test_name" &&
24 head=$(git rev-parse HEAD) &&
25 ! git push >push.out 2>push.err &&
26 cat push.err | grep "Commit $head does not reference a ticket"
29 # the last test has a dirty commit message, so ammend it with a good message
30 test_expect_success 'accept with re' '
32 git commit --amend -m "$test_name re #3222" &&
36 test_expect_success 'accept with re on second line' '
38 echo "first subject line" >msg
39 echo "second line re #322" >>msg
40 git commit -a -F msg &&
44 test_expect_success 'reject with bad message in second of three' '
45 echo "$test_name first" >a &&
46 git commit -a -m "$test_name first re #3222" &&
49 echo "$test_name second" >a &&
50 git commit -a -m "$test_name second" &&
51 head=$(git rev-parse HEAD) &&
54 echo "$test_name third" >a &&
55 git commit -a -m "$test_name third re #3222" &&
57 ! git push >push.out 2>push.err &&
58 cat push.err | grep "Commit $head does not reference a ticket"
61 test_expect_success 'accept with re in all of three' '
62 git reset --hard HEAD^^^ &&
63 echo "$test_name first" >a &&
64 git commit -a -m "$test_name first re #3222" &&
67 echo "$test_name second" >a &&
68 git commit -a -m "$test_name second re #3222" &&
69 head=$(git rev-parse HEAD) &&
71 echo "$test_name third" >a &&
72 git commit -a -m "$test_name third re #3222" &&