Test for generated patchname with trailing period
[stgit.git] / t / t2500-clean.sh
blob02703b3ab6738da39e4c518aacea6bc0bc8d7b00
1 #!/bin/sh
3 test_description='Run "stg clean"'
5 . ./test-lib.sh
7 test_expect_success 'Initialize StGit stack' '
8 stg init &&
9 stg new e0 -m e0 &&
10 stg new p0 -m p0 &&
11 echo foo > foo.txt &&
12 stg add foo.txt &&
13 stg refresh &&
14 stg new e1 -m e1 &&
15 stg new e2 -m e2 &&
16 stg pop
19 test_expect_success 'Test too many arguments' '
20 command_error stg clean p0 2>&1 |
21 grep -e "incorrect number of arguments"
24 test_expect_success 'Clean empty patches' '
25 [ "$(echo $(stg series --applied --noprefix))" = "e0 p0 e1" ] &&
26 [ "$(echo $(stg series --unapplied --noprefix))" = "e2" ] &&
27 stg clean &&
28 [ "$(echo $(stg series --applied --noprefix))" = "p0" ] &&
29 [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
32 test_expect_success 'Selectively clean applied and unapplied patches' '
33 stg new e3 -m e3 &&
34 stg new e4 -m e4 &&
35 stg pop &&
36 stg clean --applied &&
37 [ "$(echo $(stg series --applied --noprefix))" = "p0" ] &&
38 [ "$(echo $(stg series --unapplied --noprefix))" = "e4" ] &&
39 stg clean --unapplied &&
40 [ "$(echo $(stg series --applied --noprefix))" = "p0" ] &&
41 [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
44 test_expect_success 'Ensure hidden patches are not cleaned' '
45 stg new e5 -m e5 &&
46 stg hide e5 &&
47 stg clean &&
48 [ "$(echo $(stg series --applied --noprefix))" = "p0" ] &&
49 [ "$(echo $(stg series --hidden --noprefix))" = "e5" ] &&
50 [ "$(echo $(stg series --unapplied --noprefix))" = "" ] &&
51 stg unhide e5 &&
52 stg clean &&
53 [ "$(echo $(stg series --applied --noprefix))" = "p0" ] &&
54 [ "$(echo $(stg series --hidden --noprefix))" = "" ] &&
55 [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
58 test_expect_success 'Create a conflict' '
59 stg new p1 -m p1 &&
60 echo bar > foo.txt &&
61 stg refresh &&
62 stg pop &&
63 stg new p2 -m p2
64 echo quux > foo.txt &&
65 stg refresh &&
66 conflict stg push
69 test_expect_success 'Make sure conflicting patches are preserved' '
70 stg clean &&
71 [ "$(echo $(stg series --applied --noprefix))" = "p0 p2 p1" ] &&
72 [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
75 test_done