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