Test making a lightweight tag.
[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 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 tag branch' '
38         old_commit_hash=$(git rev-parse HEAD) &&
39         echo "$test_name" >a &&
40         git commit -a -m "$test_name" &&
41         prior_commit_hash=$(git rev-parse HEAD) &&
42         prior_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) &&
43
44         echo "$test_name 2" >a &&
45         git commit -a -m "$test_name 2" &&
46         new_commit_hash=$(git rev-parse HEAD) &&
47         new_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) &&
48
49         git push &&
50         new_commit_abbrev=$(git rev-list -n 1 --pretty=format:%h HEAD | grep -v commit) &&
51         interpolate ../t2201-2.txt 2.txt old_commit_hash new_commit_hash new_commit_date new_commit_abbrev prior_commit_hash prior_commit_date &&
52         test_cmp 2.txt server/.git/refs.heads.master.out
53 '
54
55 test_expect_success 'retag branch' '
56         git tag -a -m 2.0 2.0 &&
57         git push --tags &&
58         new_commit_hash=$(git rev-parse HEAD) &&
59         tag_hash=$(git rev-parse 2.0) &&
60         eval $(git for-each-ref --shell "--format=tag_date=%(taggerdate)" refs/tags/2.0) &&
61
62         interpolate ../t2201-3.txt 3.txt new_commit_hash tag_hash tag_date &&
63         test_cmp 3.txt server/.git/refs.tags.2.0.out
64 '
65
66 test_expect_success 'create lightweight tag' '
67         echo "$test_name" >a &&
68         git commit -a -m "$test_name" &&
69     git push &&
70
71         git tag 2.1 &&
72         git push --tags &&
73         new_commit_hash=$(git rev-parse HEAD) &&
74         new_commit_describe=$(git describe HEAD) &&
75         new_commit_date=$(git rev-list --no-walk --pretty=format:%ad HEAD | tail -n 1) &&
76
77         interpolate ../t2201-4.txt 4.txt new_commit_hash new_commit_describe new_commit_date &&
78         test_cmp 4.txt server/.git/refs.tags.2.1.out
79 '
80
81 test_done
82