I'm not ready to enforce that all tips must be new quite yet.
[git-central.git] / tests / t5400-script-refollow.sh
1 #!/bin/sh
2
3 test_description='script refollow'
4
5 . ./test-lib.sh
6
7 export PATH=$PATH:../../scripts
8
9 test_expect_success 'setup' '
10         echo "setup" >a &&
11         git add a &&
12         git commit -m "setup" &&
13         git clone ./. server &&
14         rm -fr server/.git/hooks &&
15         git remote add origin ./server &&
16         git checkout -b stable &&
17         git push origin stable
18 '
19
20 test_expect_success 'setup gitconfig' '
21         make-gitconfig-branch &&
22         git checkout gitconfig &&
23         echo "hooks.update-ensure-follows.branches=stable" >>config &&
24         echo "hooks.update-ensure-follows.excused=master gitconfig" >>config &&
25         git commit -a -m "enable update-ensure-follows" &&
26         git push origin gitconfig
27 '
28
29 test_expect_success 'make topic1 then move stable' '
30         git checkout -b topic1 stable &&
31         echo "$test_name" >a.topic1 &&
32         git add a.topic1 &&
33         git commit -m "$test_name on topic1" &&
34         git push origin topic1 &&
35
36         git checkout stable &&
37         echo "$test_name" >a &&
38         git commit -a -m "$test_name on stable" &&
39         git push
40 '
41
42 test_expect_success 'refollow fails with dirty index' '
43         echo "$test_name" >a &&
44         git add a &&
45         ! gc-refollow 2>refollow.err &&
46         cat refollow.err | grep "refusing to refollow--your index is not clean" &&
47         ! git reset a
48 '
49
50 test_expect_success 'refollow topic1 onto stable' '
51         echo "$test_name" >a &&
52         git commit -a -m "move stable" &&
53         git push origin stable &&
54         gc-refollow >refollow.out &&
55         cat refollow.out | grep "Merging stable into topic1...succeeded"
56
57         git checkout topic1 &&
58         git pull origin topic1 &&
59         cat a | grep "$test_name"
60 '
61
62 test_expect_success 'refollow does not double tap' '
63         # Still on topic1
64         head=$(git rev-parse HEAD) &&
65         gc-refollow &&
66         git pull origin topic1 &&
67         git rev-parse HEAD | grep $head
68 '
69
70 test_expect_success 'refollow respects excused' '
71         git checkout gitconfig &&
72         head=$(git rev-parse HEAD) &&
73
74         git checkout stable &&
75         echo "$test_name" >a &&
76         git commit -a -m "move stable" &&
77         git push origin stable &&
78
79         gc-refollow &&
80
81         git checkout gitconfig &&
82         git pull origin gitconfig &&
83         git rev-parse HEAD | grep $head
84 '
85
86 test_expect_success 'refollow continues on conflict' '
87         git checkout -b topic2 stable &&
88         echo "$test_name" >a &&
89         git commit -a -m "create topic2" &&
90         git push origin topic2 &&
91
92         git checkout stable &&
93         echo "$test_name" >a &&
94         git commit -a -m "move stable" &&
95         git push origin stable &&
96
97         gc-refollow > refollow.out &&
98         cat refollow.out | grep "Merging stable into topic1...succeeded"
99         cat refollow.out | grep "Merging stable into topic2...failed merge"
100 '
101
102 test_done
103