3 test_description='server post-receive email notification'
7 export USER_EMAIL=author@example.com
9 test_expect_success 'setup' '
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
23 install_post_receive_hook 'post-receive-email'
25 test_expect_success 'create annotated tag' '
26 git tag -a -m 1.0 1.0 &&
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) &&
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
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) &&
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) &&
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) &&
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
58 test_expect_success 're-annotated tag branch' '
59 git tag -a -m 2.0 2.0 &&
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) &&
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
69 test_expect_success 'force update annotated tag' '
70 old_tag_hash=$(git rev-parse 2.0) &&
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) &&
77 git tag -f -a -m 2.0 2.0 &&
79 new_tag_hash=$(git rev-parse 2.0) &&
80 eval $(git for-each-ref --shell "--format=tag_date=%(taggerdate)" refs/tags/2.0) &&
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
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) &&
91 git push origin :refs/tags/2.0 &&
93 new_commit_describe=$(git describe HEAD) &&
94 new_commit_hash=$(git rev-parse HEAD) &&
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
100 test_expect_success 'create lightweight tag' '
101 echo "$test_name" >a &&
102 git commit -a -m "$test_name" &&
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) &&
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
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" &&
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) &&
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
131 test_expect_success 'delete lightweight tag' '
132 old_commit_hash=$(git rev-parse HEAD) &&
133 old_commit_describe=$(git describe HEAD) &&
135 git push origin :refs/tags/2.1 &&
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