Test the conflict diff email.
[git-central.git] / tests / t2204-server-post-receive-email-conflicts.sh
1 #!/bin/sh
2
3 test_description='server post-receive email notification and how it behaves in our stable-based envrionment'
4
5 . ./test-lib.sh
6
7 export USER=author
8
9 test_expect_success 'setup' '
10         echo "setup" >a &&
11         echo "setup" >b &&
12         echo "setup" >c &&
13         git add a b c &&
14         git commit -m "setup" &&
15         git clone ./. server &&
16         rm -fr server/.git/hooks &&
17         git remote add origin ./server &&
18         git config --add branch.master.remote origin &&
19         git config --add branch.master.merge refs/heads/master &&
20         GIT_DIR=./server/.git git config --add hooks.post-receive-email.mailinglist commits@list.com &&
21         GIT_DIR=./server/.git git config --add hooks.post-receive-email.debug true &&
22         GIT_DIR=. &&
23         echo cbas >./server/.git/description &&
24
25         git checkout -b stable &&
26         git push origin stable
27 '
28
29 install_post_receive_hook 'post-receive-email'
30
31 test_expect_success 'conflict diff' '
32         git checkout stable &&
33         echo "line1" >a &&
34         echo "line2" >>a &&
35         echo "line3" >>a &&
36         git commit -a -m "lines" &&
37         git push origin stable &&
38
39         git checkout -b topic1 stable &&
40         echo "line1.topic1" >a &&
41         echo "line2.topic1" >>a &&
42         echo "line3.topic1" >>a &&
43         git commit -a -m "lines changed on topic1" &&
44         git push origin topic1 &&
45
46         old_commit_hash=$(git rev-parse HEAD) &&
47         old_commit_abbrev=$(git rev-parse --short HEAD) &&
48
49         # Move stable
50         git checkout stable &&
51         echo "line1.stable" >a &&
52         echo "line2.stable" >>a &&
53         echo "line3.stable" >>a &&
54         git commit -a -m "lines changed on stable" &&
55         git push origin stable &&
56
57         stable_hash=$(git rev-parse HEAD) &&
58
59         git checkout topic1 &&
60         ! git merge stable &&
61
62         echo "line1.topic" >a &&
63         echo "line2.stable" >>a &&
64         echo "line3.resolved" >>a &&
65         git add a &&
66         git commit -a -m "resolved lines for merging stable into topic1" &&
67         second_stable_hash=$(git rev-parse HEAD) &&
68         git push origin topic1 &&
69
70         new_commit_hash=$(git rev-parse HEAD) &&
71         new_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) &&
72         new_commit_abbrev=$(git rev-parse --short HEAD) &&
73
74         interpolate ../t2204-1.txt 1.txt old_commit_hash old_commit_abbrev new_commit_hash new_commit_abbrev new_commit_date stable_hash &&
75         test_cmp 1.txt server/.git/refs.heads.topic1.out
76 '
77
78 test_done
79