Commit | Line | Data |
---|---|---|
9beaff2e KH |
1 | #!/bin/sh |
2 | test_description='Test stg commit' | |
3 | . ./test-lib.sh | |
4 | ||
5 | test_expect_success 'Initialize the StGIT repository' ' | |
6 | stg init | |
7 | ' | |
8 | ||
d8a700cf CM |
9 | test_expect_success 'Commit middle patch' ' |
10 | stg new -m p1 && | |
11 | stg new -m p2 && | |
12 | stg new -m p3 && | |
13 | stg new -m p4 && | |
14 | stg pop && | |
15 | stg commit p2 && | |
16 | test "$(echo $(stg series))" = "+ p1 > p3 - p4" | |
17 | ' | |
18 | ||
19 | test_expect_success 'Commit first patch' ' | |
20 | stg commit && | |
21 | test "$(echo $(stg series))" = "> p3 - p4" | |
22 | ' | |
23 | ||
24 | test_expect_success 'Commit all patches' ' | |
25 | stg push && | |
26 | stg commit -a && | |
27 | test "$(echo $(stg series))" = "" | |
28 | ' | |
29 | ||
9beaff2e KH |
30 | # stg commit with top != head should not succeed, since the committed |
31 | # patches are poptentially lost. | |
32 | test_expect_success 'Commit when top != head (should fail)' ' | |
33 | stg new -m foo && | |
34 | git reset --hard HEAD^ && | |
35 | h=$(git rev-parse HEAD) | |
36 | command_error stg commit && | |
37 | test $(git rev-parse HEAD) = $h && | |
38 | test "$(echo $(stg series))" = "> foo" | |
39 | ' | |
40 | ||
41 | test_done |