| 1 | #!/bin/sh |
| 2 | test_description='Test the pick command' |
| 3 | |
| 4 | . ./test-lib.sh |
| 5 | |
| 6 | test_expect_success \ |
| 7 | 'Initialize the StGIT repository' \ |
| 8 | ' |
| 9 | stg init && |
| 10 | stg new A -m "a" && echo A > a && git add a && stg refresh && |
| 11 | stg new B -m "b" && echo B > b && git add b && stg refresh && |
| 12 | stg branch --clone foo && |
| 13 | stg new C -m "c" && echo C > c && git add c && stg refresh && |
| 14 | stg new D-foo -m "d" && echo D > d && git add d && stg refresh && |
| 15 | stg branch master |
| 16 | ' |
| 17 | |
| 18 | test_expect_success \ |
| 19 | 'Pick remote patch' \ |
| 20 | ' |
| 21 | stg pick foo:C && |
| 22 | test "$(echo $(stg series --applied --noprefix))" = "A B C" |
| 23 | ' |
| 24 | |
| 25 | test_expect_success \ |
| 26 | 'Pick --unapplied remote patch' \ |
| 27 | ' |
| 28 | stg pick --unapplied --ref-branch foo --name D D-foo && |
| 29 | test "$(echo $(stg series --applied --noprefix))" = "A B C" && |
| 30 | test "$(echo $(stg series --unapplied --noprefix))" = "D" |
| 31 | ' |
| 32 | |
| 33 | test_expect_success \ |
| 34 | 'Pick local unapplied patch' \ |
| 35 | ' |
| 36 | stg pick D && |
| 37 | test "$(echo $(stg series --applied --noprefix))" = "A B C D-0" && |
| 38 | test "$(echo $(stg series --unapplied --noprefix))" = "D" |
| 39 | ' |
| 40 | |
| 41 | test_expect_success \ |
| 42 | 'Pick --fold --reverse local patch' \ |
| 43 | ' |
| 44 | stg pick --fold --reverse D && |
| 45 | stg refresh && stg clean && |
| 46 | test "$(echo $(stg series --applied --noprefix))" = "A B C" && |
| 47 | test "$(echo $(stg series --unapplied --noprefix))" = "D" |
| 48 | ' |
| 49 | |
| 50 | test_expect_success \ |
| 51 | 'Pick --fold without applied patches' \ |
| 52 | ' |
| 53 | stg pop --all && |
| 54 | stg pick --fold D && |
| 55 | test "$(echo $(stg series --unapplied --noprefix))" = "A B C D" && |
| 56 | test "$(echo $(stg status))" = "A d" |
| 57 | ' |
| 58 | |
| 59 | test_done |