Better tattoo.
[git-central.git] / tests / t5500-script-tattoo.sh
1 #!/bin/sh
2
3 test_description='script tattoo'
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 # tattoo makes assumptions based on the update stable hook sanity checks
21 install_update_hook 'update-stable'
22
23 test_expect_success 'tattoo of first commit' '
24         gc-tattoo | grep 0
25 '
26
27 test_expect_success 'tattoo 1' '
28         git checkout -b topic1 &&
29         echo "$test_name" >a.topic1 &&
30         git add a.topic1 &&
31         git commit -a -m "move topic1-1" &&
32         git push origin topic1 &&
33         gc-tattoo | grep topic1-1
34 '
35
36 test_expect_success 'tattoo 2' '
37         echo "$test_name" >a &&
38         git commit -a -m "make topic1-2" &&
39         git push origin topic1 &&
40         gc-tattoo | grep topic1-2
41 '
42
43 test_expect_success 'merge topic2 into topic1 as tattoo 3' '
44         git checkout -b topic2 stable &&
45         echo "$test_name" >a.topic2 &&
46         git add a.topic2 &&
47         git commit -m "make topic2-1" &&
48         git push origin topic2 &&
49         gc-tattoo | grep topic2-1 &&
50
51         git checkout topic1 &&
52         git merge topic2 &&
53         git push origin topic1 &&
54         gc-tattoo | grep topic1-3 &&
55
56         git checkout topic2 &&
57         gc-tattoo | grep topic2-1
58 '
59
60 test_expect_success 'fails if not pushed' '
61         git checkout topic1 &&
62         echo "$test_name" >a &&
63         git commit -a -m "make topic1-4" &&
64         head=$(git rev-parse HEAD) &&
65         gc-tattoo | grep "$head has not been pushed" &&
66         git push origin topic1 &&
67         gc-tattoo | grep topic1-4
68 '
69
70 test_expect_success 'stable fails if not pushed' '
71         git checkout stable &&
72         git merge --no-ff topic1 &&
73         head=$(git rev-parse HEAD) &&
74         gc-tattoo | grep "$head has not been pushed" &&
75         git push &&
76         gc-tattoo | grep "stable-$head"
77 '
78
79 test_expect_success 'stable without a tag' '
80         git checkout stable &&
81         head=$(git rev-parse HEAD) &&
82         gc-tattoo | grep "stable-$head"
83 '
84
85 test_expect_success 'stable with a tag' '
86         git tag -m "1.0" 1.0 &&
87         gc-tattoo | grep "1.0"
88 '
89
90 test_expect_success 'use origin stable not local' '
91         git checkout origin/stable &&
92         git branch -d stable &&
93         git checkout topic2 &&
94         gc-tattoo | grep "topic2-1"
95 '
96
97 test_done
98