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