3 test_description='server post-receive email notification'
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 --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 &&
21 echo cbas >./server/.git/description
24 install_post_receive_hook 'post-receive-email'
26 test_expect_success 'create branch' '
27 git checkout -b topic master &&
28 echo "$test_name" >a &&
29 git commit -a -m "$test_name on topic" &&
30 prior_commit_hash=$(git rev-parse HEAD) &&
31 prior_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) &&
33 echo "$test_name 2" >a &&
34 git commit -a -m "$test_name on topic 2 " &&
35 new_commit_hash=$(git rev-parse HEAD) &&
36 new_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) &&
38 git push origin topic &&
40 interpolate ../t2202-1.txt 1.txt new_commit_hash new_commit_date prior_commit_hash prior_commit_date &&
41 test_cmp 1.txt server/.git/refs.heads.topic.out
44 test_expect_success 'create branch with existing commits does not replay them' '
45 git checkout -b topic2 topic &&
46 existing_commit_hash=$(git rev-parse HEAD) &&
47 existing_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) &&
49 git push origin topic2 &&
51 interpolate ../t2202-3.txt 3.txt existing_commit_hash existing_commit_date &&
52 test_cmp 3.txt server/.git/refs.heads.topic2.out
55 test_expect_success 'update branch with existing commits does not replay them' '
56 # Put a commit on topic2, then fast foward topic to it
57 git checkout topic2 &&
58 echo "$test_name" >a &&
59 git commit -a -m "$test_name on topic" &&
63 old_commit_hash=$(git rev-parse HEAD) &&
65 existing_commit_hash=$(git rev-parse HEAD) &&
68 interpolate ../t2202-4.txt 4.txt old_commit_hash existing_commit_hash &&
69 test_cmp 4.txt server/.git/refs.heads.topic.out
72 test_expect_success 'delete branch' '
73 old_commit_hash=$(git rev-parse HEAD) &&
74 git push origin :refs/heads/topic &&
76 interpolate ../t2202-2.txt 2.txt old_commit_hash &&
77 test_cmp 2.txt server/.git/refs.heads.topic.out