3 test_description='script refollow'
7 export PATH=$PATH:../../scripts
9 test_expect_success 'setup' '
12 git commit -m "setup" &&
13 git clone -l . --bare server.git &&
14 rm -fr server.git/hooks &&
15 git remote add origin ./server.git &&
16 git checkout -b stable &&
17 git push origin stable
20 test_expect_success 'setup gitconfig' '
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
29 test_expect_success 'make topic1 then move stable' '
30 git checkout -b topic1 stable &&
31 echo "$test_name" >a.topic1 &&
33 git commit -m "$test_name on topic1" &&
34 git push origin topic1 &&
36 git checkout stable &&
37 echo "$test_name" >a &&
38 git commit -a -m "$test_name on stable" &&
42 test_expect_success 'refollow fails with dirty index' '
43 echo "$test_name" >a &&
45 ! refollow 2>refollow.err &&
46 cat refollow.err | grep "refusing to refollow--your index is not clean" &&
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 refollow >refollow.out &&
55 cat refollow.out | grep "Merging stable into topic1...succeeded"
57 git checkout topic1 &&
58 git pull origin topic1 &&
59 cat a | grep "$test_name"
62 test_expect_success 'refollow does not double tap' '
64 head=$(git rev-parse HEAD) &&
66 git pull origin topic1 &&
67 git rev-parse HEAD | grep $head
70 test_expect_success 'refollow respects excused' '
71 git checkout gitconfig &&
72 head=$(git rev-parse HEAD) &&
74 git checkout stable &&
75 echo "$test_name" >a &&
76 git commit -a -m "move stable" &&
77 git push origin stable &&
81 git checkout gitconfig &&
82 git pull origin gitconfig &&
83 git rev-parse HEAD | grep $head
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 &&
92 git checkout stable &&
93 echo "$test_name" >a &&
94 git commit -a -m "move stable" &&
95 git push origin stable &&
97 refollow > refollow.out &&
98 cat refollow.out | grep "Merging stable into topic1...succeeded"
99 cat refollow.out | grep "Merging stable into topic2...failed merge"