Adding a functions and redoing the tattoo to use the r/X tags.
[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 install_post_receive_hook 'post-receive-assign-commit-numbers'
23
24 test_expect_success 'tattoo of unpublished commit fails' '
25         gc-tattoo | grep "No commit number tag found"
26 '
27
28 test_done
29
30 test_expect_success 'tattoo 1' '
31         git checkout -b topic1 &&
32         echo "$test_name" >a.topic1 &&
33         git add a.topic1 &&
34         git commit -a -m "move topic1-1" &&
35         git push origin topic1 &&
36         gc-tattoo | grep topic1-1
37 '
38
39 test_expect_success 'tattoo 2' '
40         echo "$test_name" >a &&
41         git commit -a -m "make topic1-2" &&
42         git push origin topic1 &&
43         gc-tattoo | grep topic1-2
44 '
45
46 test_expect_success 'merge topic2 into topic1 as tattoo 3' '
47         git checkout -b topic2 stable &&
48         echo "$test_name" >a.topic2 &&
49         git add a.topic2 &&
50         git commit -m "make topic2-1" &&
51         git push origin topic2 &&
52         gc-tattoo | grep topic2-1 &&
53
54         git checkout topic1 &&
55         git merge topic2 &&
56         git push origin topic1 &&
57         gc-tattoo | grep topic1-3 &&
58
59         git checkout topic2 &&
60         gc-tattoo | grep topic2-1
61 '
62
63 test_expect_success 'fails if not pushed' '
64         git checkout topic1 &&
65         echo "$test_name" >a &&
66         git commit -a -m "make topic1-4" &&
67         head=$(git rev-parse HEAD) &&
68         gc-tattoo | grep "$head has not been pushed" &&
69         git push origin topic1 &&
70         gc-tattoo | grep topic1-4
71 '
72
73 test_expect_success 'stable fails if not pushed' '
74         git checkout stable &&
75         git merge --no-ff topic1 &&
76         head=$(git rev-parse HEAD) &&
77         gc-tattoo | grep "$head has not been pushed" &&
78         git push &&
79         gc-tattoo | grep "stable-$head"
80 '
81
82 test_expect_success 'stable without a tag' '
83         git checkout stable &&
84         head=$(git rev-parse HEAD) &&
85         gc-tattoo | grep "stable-$head"
86 '
87
88 test_expect_success 'stable with a tag' '
89         git tag -m "1.0" 1.0 &&
90         gc-tattoo | grep "1.0"
91 '
92
93 test_expect_success 'use origin stable not local' '
94         git checkout origin/stable &&
95         git branch -d stable &&
96         git checkout topic2 &&
97         gc-tattoo | grep "topic2-1"
98 '
99
100 test_done
101