bf545f97209551aefdfcde892db92192a4766419
[git-central.git] / tests / t2203-server-post-receive-email-stable.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_EMAIL=author@example.com
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 branch.master.remote origin &&
19         git config branch.master.merge refs/heads/master &&
20         GIT_DIR=./server/.git git config hooks.post-receive-email.mailinglist commits@list.com &&
21         GIT_DIR=./server/.git git config hooks.post-receive-email.debug true &&
22         echo cbas >./server/.git/description &&
23
24         git checkout -b stable &&
25         git push origin stable
26 '
27
28 install_post_receive_hook 'post-receive-email'
29
30 test_expect_success 'merge in stable' '
31         git checkout -b topic1 stable &&
32         echo "move" >a.topic1 &&
33         git add a.topic1 &&
34         git commit -a -m "move topic1" &&
35         git push origin topic1 &&
36         old_commit_hash=$(git rev-parse HEAD) &&
37         old_commit_abbrev=$(git rev-parse --short HEAD) &&
38
39         # Move stable
40         git checkout stable &&
41         echo "$test_name 1" >a &&
42         echo "$test_name 1" >b &&
43         echo "$test_name 1" >c &&
44         git commit -a -m "move stable 1" &&
45         first_stable_hash=$(git rev-parse HEAD) &&
46
47         echo "$test_name 2" >a &&
48         echo "$test_name 2" >b &&
49         echo "$test_name 2" >c &&
50         git commit -a -m "move stable 2" &&
51         second_stable_hash=$(git rev-parse HEAD) &&
52         git push origin stable &&
53
54         # Merge stable
55         git checkout topic1 &&
56         git merge stable &&
57         git push &&
58
59         new_commit_hash=$(git rev-parse HEAD) &&
60         new_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) &&
61         new_commit_abbrev=$(git rev-parse --short HEAD) &&
62
63         interpolate ../t2203-1.txt 1.txt old_commit_hash old_commit_abbrev new_commit_hash new_commit_abbrev new_commit_date first_stable_hash second_stable_hash &&
64         test_cmp 1.txt server/.git/refs.heads.topic1.out
65 '
66
67 test_expect_success 'merge in stable with conflict' '
68         git checkout topic1 &&
69         echo "$test_name on topic1" >a &&
70         git commit -a -m "move topic1" &&
71         git push origin topic1 &&
72         old_commit_hash=$(git rev-parse HEAD) &&
73         old_commit_abbrev=$(git rev-parse --short HEAD) &&
74
75         # Move stable
76         git checkout stable &&
77         echo "$test_name 1" >a &&
78         echo "$test_name 1" >b &&
79         echo "$test_name 1" >c &&
80         git commit -a -m "move stable 1" &&
81         first_stable_hash=$(git rev-parse HEAD) &&
82
83         echo "$test_name 2" >a &&
84         echo "$test_name 2" >b &&
85         echo "$test_name 2" >c &&
86         git commit -a -m "move stable 2" &&
87         second_stable_hash=$(git rev-parse HEAD) &&
88         git push origin stable &&
89
90         # Merge stable
91         git checkout topic1 &&
92         ! git merge stable &&
93         echo "$test_name 2 merged topic1" >a &&
94         git add a &&
95         git commit -F .git/MERGE_MSG
96         git push &&
97
98         new_commit_hash=$(git rev-parse HEAD) &&
99         new_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) &&
100         new_commit_abbrev=$(git rev-parse --short HEAD) &&
101
102         interpolate ../t2203-2.txt 2.txt old_commit_hash old_commit_abbrev new_commit_hash new_commit_abbrev new_commit_date first_stable_hash second_stable_hash &&
103         test_cmp 2.txt server/.git/refs.heads.topic1.out
104 '
105
106 test_done
107