3 test_description='server pre-receive trac ticket enforcer via shim'
7 test_expect_success 'setup' '
8 echo This is a test. >a &&
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 'noop' 'noop'
20 install_server_hook 'pre-receive-trac' 'pre-receive-trac'
21 install_server_hook 'pre-receive-trac-then-noop' 'pre-receive'
23 test_expect_success 'reject with bad message via shim' '
25 git commit -a -m "$test_name" &&
26 head=$(git rev-parse HEAD) &&
27 ! git push >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 with re via shim' '
34 git commit --amend -m "$test_name re #3222" &&
38 test_expect_success 'reject second push line has bad message via shim' '
39 # make a new remote branch
40 git branch topic1 master &&
41 git push origin topic1 &&
45 git commit -a -m "$test_name re #3222" &&
47 # change topic1 with no re
48 git checkout topic1 &&
49 echo "$test_name topic1" >a &&
50 git commit -a -m "$test_name" &&
51 head=$(git rev-parse HEAD) &&
53 ! git push >push.out 2>push.err &&
54 cat push.err | grep "Commit $head does not reference a ticket"
57 test_expect_success 'reject first push line has bad message via shim' '
58 # make a new remote branch
59 git branch topic2 master &&
60 git push origin topic2 &&
62 # change master first with no re
64 git commit -a -m "$test_name" &&
65 head=$(git rev-parse HEAD) &&
67 # change topic2 with re
68 git checkout topic2 &&
69 echo "$test_name topic2" >a &&
70 git commit -a -m "$test_name re #3222" &&
72 ! git push >push.out 2>push.err &&
73 cat push.err | grep "Commit $head does not reference a ticket"