I'm not ready to enforce that all tips must be new quite yet.
[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=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 'merge in stable' '
32         git checkout -b topic1 stable &&
33         echo "move" >a.topic1 &&
34         git add a.topic1 &&
35         git commit -a -m "move topic1" &&
36         git push origin topic1 &&
37         old_commit_hash=$(git rev-parse HEAD) &&
38         old_commit_abbrev=$(git rev-parse --short HEAD) &&
39
40         # Move stable
41         git checkout stable &&
42         echo "$test_name 1" >a &&
43         echo "$test_name 1" >b &&
44         echo "$test_name 1" >c &&
45         git commit -a -m "move stable 1" &&
46         first_stable_hash=$(git rev-parse HEAD) &&
47
48         echo "$test_name 2" >a &&
49         echo "$test_name 2" >b &&
50         echo "$test_name 2" >c &&
51         git commit -a -m "move stable 2" &&
52         second_stable_hash=$(git rev-parse HEAD) &&
53         git push origin stable &&
54
55         # Merge stable
56         git checkout topic1 &&
57         git merge stable &&
58         git push &&
59
60         new_commit_hash=$(git rev-parse HEAD) &&
61         new_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) &&
62         new_commit_abbrev=$(git rev-parse --short HEAD) &&
63
64         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 &&
65         test_cmp 1.txt server/.git/refs.heads.topic1.out
66 '
67
68 test_expect_success 'merge in stable with conflict' '
69         git checkout topic1 &&
70         echo "$test_name on topic1" >a &&
71         git commit -a -m "move topic1" &&
72         git push origin topic1 &&
73         old_commit_hash=$(git rev-parse HEAD) &&
74         old_commit_abbrev=$(git rev-parse --short HEAD) &&
75
76         # Move stable
77         git checkout stable &&
78         echo "$test_name 1" >a &&
79         echo "$test_name 1" >b &&
80         echo "$test_name 1" >c &&
81         git commit -a -m "move stable 1" &&
82         first_stable_hash=$(git rev-parse HEAD) &&
83
84         echo "$test_name 2" >a &&
85         echo "$test_name 2" >b &&
86         echo "$test_name 2" >c &&
87         git commit -a -m "move stable 2" &&
88         second_stable_hash=$(git rev-parse HEAD) &&
89         git push origin stable &&
90
91         # Merge stable
92         git checkout topic1 &&
93         ! git merge stable &&
94         echo "$test_name 2 merged topic1" >a &&
95         git add a &&
96         git commit -F .git/MERGE_MSG
97         git push &&
98
99         new_commit_hash=$(git rev-parse HEAD) &&
100         new_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) &&
101         new_commit_abbrev=$(git rev-parse --short HEAD) &&
102
103         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 &&
104         test_cmp 2.txt server/.git/refs.heads.topic1.out
105 '
106
107 test_done
108