Pass the output of git describe --tags to trac as well.
[git-central.git] / tests / t3001-server-post-receive-trac-with-commit-numbers.sh
1 #!/bin/sh
2
3 test_description='server post receive trac with commit numbers'
4
5 . ./test-lib.sh
6
7 export PYTHON=echo
8 export POST_RECEIVE_TRAC=/foo/post-receive-trac.py
9 export TRAC_ENV=/foo/trac
10
11 test_expect_success 'setup' '
12         echo "setup" >a &&
13         git add a &&
14         git commit -m "setup" &&
15         git clone ./. server &&
16         rm -fr server/.git/hooks &&
17         git remote add origin ./server
18 '
19
20 install_post_receive_hook 'post-receive-assign-commit-numbers' 'post-receive-trac'
21
22 test_expect_success 'new branch' '
23         git checkout -b topic1 master &&
24         echo "$test_name" >a &&
25         git commit -a -m "changed on topic1" &&
26         new_commit_hash=$(git rev-parse HEAD) &&
27         git push origin topic1 2>push.err &&
28         cat push.err | grep "/foo/post-receive-trac.py /foo/trac topic1 $new_commit_hash r/1 $new_commit_hash"
29 '
30
31 test_expect_success 'new branch with already existing does not double tap' '
32         git checkout -b topic2 topic1 &&
33         existing_commit_hash=$(git rev-parse HEAD) &&
34         git push origin topic2 2>push.err &&
35         ! cat push.err | grep "/foo/post-receive-trac.py /foo/trac topic2"
36 '
37
38 test_expect_success 'update branch' '
39         # Already on topic2
40         echo "$test_name" >a &&
41         git commit -a -m "changed on topic2" &&
42         new_commit_hash=$(git rev-parse HEAD) &&
43         git push origin topic2 2>push.err &&
44         cat push.err | grep "/foo/post-receive-trac.py /foo/trac topic2 $new_commit_hash r/2 $new_commit_hash"
45 '
46
47 test_expect_success 'update branch to an already published commit does not double tap' '
48         # Make topic1 catch up to topic2, which will be a fast forward that does need re-tapped
49         git checkout topic2 &&
50         topic2_hash=$(git rev-parse HEAD) &&
51
52         git checkout topic1 &&
53         git merge topic2 &&
54         topic1_hash=$(git rev-parse HEAD) &&
55
56         git push 2>push.err &&
57
58         ! cat push.err | grep "/foo/post-receive-trac.py /foo/trac topic2"
59         ! cat push.err | grep "/foo/post-receive-trac.py /foo/trac topic1"
60 '
61
62 test_expect_success 'update branch with abbreviation' '
63         git checkout topic2
64         git tag -m "release1" release1 &&
65         git push --tags &&
66
67         echo "$test_name" >a &&
68         git commit -a -m "changed on topic2" &&
69         new_commit_describe=$(git describe HEAD) &&
70         new_commit_hash=$(git rev-parse HEAD) &&
71         git push origin topic2 2>push.err &&
72         cat push.err | grep "/foo/post-receive-trac.py /foo/trac topic2 $new_commit_describe r/3 $new_commit_hash"
73 '
74
75 test_expect_success 'update branch with abbreviation and two commits' '
76         echo "$test_name 1" >a &&
77         git commit -a -m "changed on topic2 1" &&
78         first_commit_describe=$(git describe HEAD) &&
79         first_commit_hash=$(git rev-parse HEAD) &&
80
81         echo "$test_name 2" >a &&
82         git commit -a -m "changed on topic2 2" &&
83         second_commit_describe=$(git describe HEAD) &&
84         second_commit_hash=$(git rev-parse HEAD) &&
85
86         git push origin topic2 2>push.err &&
87         cat push.err | grep "/foo/post-receive-trac.py /foo/trac topic2 $first_commit_describe r/4 $first_commit_hash" &&
88         cat push.err | grep "/foo/post-receive-trac.py /foo/trac topic2 $second_commit_describe r/5 $second_commit_hash"
89 '
90
91 test_done
92