Fix post-receive-email test for USER_EMAIL variable.
[git-central.git] / tests / t2201-server-post-receive-email-tags.sh
1 #!/bin/sh
2
3 test_description='server post-receive email notification'
4
5 . ./test-lib.sh
6
7 export USER_EMAIL=author@example.com
8
9 test_expect_success 'setup' '
10         echo "setup" >a &&
11         git add a &&
12         git commit -m "setup" &&
13         git clone ./. server &&
14         rm -fr server/.git/hooks &&
15         git remote add origin ./server &&
16         git config branch.master.remote origin &&
17         git config branch.master.merge refs/heads/master &&
18         GIT_DIR=./server/.git git config hooks.post-receive-email.mailinglist commits@list.com &&
19         GIT_DIR=./server/.git git config hooks.post-receive-email.debug true &&
20         echo cbas >./server/.git/description
21 '
22
23 install_post_receive_hook 'post-receive-email'
24
25 test_expect_success 'create annotated tag' '
26         git tag -a -m 1.0 1.0 &&
27         git push --tags &&
28         new_commit_hash=$(git rev-parse HEAD) &&
29         tag_hash=$(git rev-parse 1.0) &&
30         eval $(git for-each-ref --shell "--format=tag_date=%(taggerdate)" refs/tags/1.0) &&
31
32         interpolate ../t2201-1.txt 1.txt new_commit_hash tag_hash tag_date &&
33         test_cmp 1.txt server/.git/refs.tags.1.0.out
34 '
35
36 test_expect_success 'commit on annotated tagged branch' '
37         old_commit_hash=$(git rev-parse HEAD) &&
38         old_commit_abbrev=$(git rev-parse --short HEAD) &&
39
40         echo "$test_name" >a &&
41         git commit -a -m "$test_name" &&
42         prior_commit_hash=$(git rev-parse HEAD) &&
43         prior_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) &&
44         prior_commit_abbrev=$(git rev-parse --short HEAD) &&
45
46         echo "$test_name 2" >a &&
47         git commit -a -m "$test_name 2" &&
48         new_commit_hash=$(git rev-parse HEAD) &&
49         new_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) &&
50         new_commit_abbrev=$(git rev-parse --short HEAD) &&
51
52         git push &&
53         new_commit_abbrev=$(git rev-list -n 1 --pretty=format:%h HEAD | grep -v commit) &&
54         interpolate ../t2201-2.txt 2.txt old_commit_hash new_commit_hash new_commit_date new_commit_abbrev prior_commit_hash prior_commit_date old_commit_abbrev prior_commit_abbrev new_commit_abbrev &&
55         test_cmp 2.txt server/.git/refs.heads.master.out
56 '
57
58 test_expect_success 're-annotated tag branch' '
59         git tag -a -m 2.0 2.0 &&
60         git push --tags &&
61         new_commit_hash=$(git rev-parse HEAD) &&
62         tag_hash=$(git rev-parse 2.0) &&
63         eval $(git for-each-ref --shell "--format=tag_date=%(taggerdate)" refs/tags/2.0) &&
64
65         interpolate ../t2201-3.txt 3.txt new_commit_hash tag_hash tag_date &&
66         test_cmp 3.txt server/.git/refs.tags.2.0.out
67 '
68
69 test_expect_success 'force update annotated tag' '
70         old_tag_hash=$(git rev-parse 2.0) &&
71
72         echo "$test_name" >a &&
73         git commit -a -m "$test_name" &&
74         new_commit_hash=$(git rev-parse HEAD) &&
75         new_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) &&
76
77         git tag -f -a -m 2.0 2.0 &&
78         git push --tags &&
79         new_tag_hash=$(git rev-parse 2.0) &&
80         eval $(git for-each-ref --shell "--format=tag_date=%(taggerdate)" refs/tags/2.0) &&
81
82         interpolate ../t2201-7.txt 7.txt old_tag_hash new_commit_hash new_tag_hash tag_date &&
83         test_cmp 7.txt server/.git/refs.tags.2.0.out
84 '
85
86 test_expect_success 'delete annotated tag' '
87         old_tag_hash=$(git rev-parse 2.0) &&
88         eval $(git for-each-ref --shell "--format=old_tag_date=%(taggerdate)" refs/tags/2.0) &&
89
90         git tag -d 2.0 &&
91         git push origin :refs/tags/2.0 &&
92
93         new_commit_describe=$(git describe HEAD) &&
94         new_commit_hash=$(git rev-parse HEAD) &&
95
96         interpolate ../t2201-8.txt 8.txt old_tag_hash old_tag_date new_commit_describe new_commit_hash &&
97         test_cmp 8.txt server/.git/refs.tags.2.0.out
98 '
99
100 test_expect_success 'create lightweight tag' '
101         echo "$test_name" >a &&
102         git commit -a -m "$test_name" &&
103         git push &&
104
105         git tag 2.1 &&
106         git push --tags &&
107         new_commit_hash=$(git rev-parse HEAD) &&
108         new_commit_describe=$(git describe HEAD) &&
109         new_commit_date=$(git rev-list --no-walk --pretty=format:%ad HEAD | tail -n 1) &&
110
111         interpolate ../t2201-4.txt 4.txt new_commit_hash new_commit_describe new_commit_date &&
112         test_cmp 4.txt server/.git/refs.tags.2.1.out
113 '
114
115 test_expect_success 'force update lightweight tag' '
116         old_commit_hash=$(git rev-parse HEAD) &&
117         echo "$test_name" >a &&
118         git commit -a -m "$test_name" &&
119         git push &&
120
121         git tag -f 2.1 &&
122         git push --tags &&
123         new_commit_hash=$(git rev-parse HEAD) &&
124         new_commit_describe=$(git describe HEAD) &&
125         new_commit_date=$(git rev-list --no-walk --pretty=format:%ad HEAD | tail -n 1) &&
126
127         interpolate ../t2201-5.txt 5.txt new_commit_hash new_commit_describe new_commit_date old_commit_hash &&
128         test_cmp 5.txt server/.git/refs.tags.2.1.out
129 '
130
131 test_expect_success 'delete lightweight tag' '
132         old_commit_hash=$(git rev-parse HEAD) &&
133         old_commit_describe=$(git describe HEAD) &&
134         git tag -d 2.1 &&
135         git push origin :refs/tags/2.1 &&
136
137         interpolate ../t2201-6.txt 6.txt old_commit_hash old_commit_describe &&
138         test_cmp 6.txt server/.git/refs.tags.2.1.out
139 '
140
141 test_done
142