More email tests.
[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 test_expect_success 'setup' '
8         echo "setup" >a &&
9         git add a &&
10         git commit -m "setup" &&
11         git clone ./. server &&
12         rm -fr server/.git/hooks &&
13         git remote add origin ./server &&
14         git config --add branch.master.remote origin &&
15         git config --add branch.master.merge refs/heads/master &&
16         GIT_DIR=./server/.git git config --add hooks.mailinglist commits@list.com &&
17         GIT_DIR=./server/.git git config --add hooks.debug true &&
18         GIT_DIR=.
19 '
20
21 install_server_hook 'post-receive-email' 'post-receive'
22
23 test_expect_success 'create tag' '
24         git tag -a -m 1.0 1.0 &&
25         git push --tags &&
26         new_commit_hash=$(git rev-parse HEAD) &&
27         tag_hash=$(git rev-parse 1.0) &&
28         eval $(git for-each-ref --shell "--format=tag_date=%(taggerdate)" refs/tags/1.0) &&
29
30         interpolate ../t2201-1.txt 1.txt new_commit_hash tag_hash tag_date &&
31         test_cmp 1.txt server/.git/refs.tags.1.0.out
32 '
33
34 test_expect_success 'commit on tag branch' '
35         old_commit_hash=$(git rev-parse HEAD) &&
36         echo "$test_name" >a &&
37         git commit -a -m "$test_name" &&
38         prior_commit_hash=$(git rev-parse HEAD) &&
39         prior_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) &&
40
41         echo "$test_name 2" >a &&
42         git commit -a -m "$test_name 2" &&
43         new_commit_hash=$(git rev-parse HEAD) &&
44         new_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) &&
45
46         git push &&
47         new_commit_abbrev=$(git rev-list -n 1 --pretty=format:%h HEAD | grep -v commit) &&
48         interpolate ../t2201-2.txt 2.txt old_commit_hash new_commit_hash new_commit_date new_commit_abbrev prior_commit_hash prior_commit_date &&
49         test_cmp 2.txt server/.git/refs.heads.master.out
50 '
51
52 test_expect_success 'retag branch' '
53         git tag -a -m 2.0 2.0 &&
54         git push --tags &&
55         new_commit_hash=$(git rev-parse HEAD) &&
56         tag_hash=$(git rev-parse 2.0) &&
57         eval $(git for-each-ref --shell "--format=tag_date=%(taggerdate)" refs/tags/2.0) &&
58
59         interpolate ../t2201-3.txt 3.txt new_commit_hash tag_hash tag_date &&
60         test_cmp 3.txt server/.git/refs.tags.2.0.out
61 '
62
63 test_done
64