3 # Copyright (c) 2009 Catalin Marinas
6 test_description
='Exercise the publish command.
8 Create/modify patches on the stack and publish them to a separate branch.'
13 stack_tree
=$
(git rev-parse master^
{tree
})
14 public_tree
=$
(git rev-parse master.public^
{tree
})
15 test "$stack_tree" = "$public_tree"
19 'Initialize the StGit repository' \
25 'Create some patches' \
28 echo foo1 > foo1.txt &&
32 echo foo2 > foo2.txt &&
36 echo foo3 > foo3.txt &&
42 'Publish the stack for the first time' \
45 test "$(stg id)" = "$(stg id master.public)"
49 'Modify a patch and publish the changes' \
52 echo foo2 >> foo2.txt &&
55 old_public=$(stg id master.public) &&
56 stg publish -m "p2 updated" &&
58 new_public=$(stg id master.public) &&
59 test $(git rev-list $old_public..$new_public | wc -l) -eq 1
63 'Create new patches and publish them' \
66 echo foo4 > foo4.txt &&
70 echo foo5 > foo5.txt &&
73 stg new empty -m empty &&
74 old_public=$(stg id master.public) &&
75 stg publish -m "Ignored message" &&
77 new_public=$(stg id master.public) &&
78 test $(git rev-list $old_public..$new_public | wc -l) -eq 2
82 'Rebase the current stack and publish a merge' \
85 echo foo0 > foo0.txt &&
87 git commit -m "foo0.txt added" &&
89 old_public=$(stg id master.public) &&
90 stg publish -m "Merge with base" &&
92 new_public=$(stg id master.public) &&
93 test $(git rev-list $old_public..$new_public | wc -l) -eq 2 &&
94 test "$(git merge-base master.public master)" = "$(stg id {base})"
98 'Re-publish without any changes' \
100 old_public=$(stg id master.public) &&
101 stg publish -m "Ignored message" &&
103 new_public=$(stg id master.public) &&
104 test "$old_public" = "$new_public"
107 test_expect_success \
108 'Reorder patches and publish the changes' \
110 stg float p5 p4 p3 p2 p1 &&
111 old_public=$(stg id master.public) &&
112 stg publish -m "Ignored message" &&
114 new_public=$(stg id master.public) &&
115 test "$old_public" = "$new_public"
118 test_expect_success \
119 'Pop a patch and publish the changes' \
122 old_public=$(stg id master.public) &&
123 stg publish -m "p3 removed" &&
125 new_public=$(stg id master.public) &&
126 test $(git rev-list $old_public..$new_public | wc -l) -eq 1