Commit | Line | Data |
---|---|---|
48b209cd KH |
1 | #!/bin/sh |
2 | ||
594aa463 | 3 | test_description='Run "stg squash"' |
48b209cd KH |
4 | |
5 | . ./test-lib.sh | |
6 | ||
7 | test_expect_success 'Initialize StGit stack' ' | |
8 | stg init && | |
9 | for i in 0 1 2 3; do | |
10 | stg new p$i -m "foo $i" && | |
11 | echo "foo $i" >> foo.txt && | |
c7506039 | 12 | stg add foo.txt && |
48b209cd KH |
13 | stg refresh |
14 | done | |
15 | ' | |
16 | ||
594aa463 | 17 | test_expect_success 'Squash some patches' ' |
f9d9a062 CM |
18 | [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2 p3" ] && |
19 | [ "$(echo $(stg series --unapplied --noprefix))" = "" ] && | |
594aa463 | 20 | stg squash --name=q0 --message="wee woo" p1 p2 && |
f9d9a062 CM |
21 | [ "$(echo $(stg series --applied --noprefix))" = "p0 q0 p3" ] && |
22 | [ "$(echo $(stg series --unapplied --noprefix))" = "" ] | |
48b209cd KH |
23 | ' |
24 | ||
594aa463 KH |
25 | test_expect_success 'Squash at stack top' ' |
26 | stg squash --name=q1 --message="wee woo wham" q0 p3 && | |
f9d9a062 CM |
27 | [ "$(echo $(stg series --applied --noprefix))" = "p0 q1" ] && |
28 | [ "$(echo $(stg series --unapplied --noprefix))" = "" ] | |
48b209cd KH |
29 | ' |
30 | ||
c539d625 KH |
31 | cat > editor <<EOF |
32 | #!/bin/sh | |
33 | echo "Editor was invoked" | tee editor-invoked | |
34 | EOF | |
35 | chmod a+x editor | |
594aa463 | 36 | test_expect_success 'Squash with top != head' ' |
c539d625 KH |
37 | echo blahonga >> foo.txt && |
38 | git commit -a -m "a new commit" && | |
594aa463 | 39 | EDITOR=./editor command_error stg squash --name=r0 p0 q1 && |
c539d625 KH |
40 | test "$(echo $(stg series))" = "+ p0 > q1" && |
41 | test ! -e editor-invoked | |
42 | ' | |
43 | ||
48b209cd | 44 | test_done |