3 test_description
='Branch cleanup'
7 test_expect_success
'Initialize branch' '
9 stg branch --create foo &&
16 test_expect_success
'Cannot cleanup with patches' '
17 command_error stg branch --cleanup 2>err &&
18 grep "Cannot clean up: the series still contains patches" err
21 test_expect_success
'Cannot cleanup with unapplied patches' '
23 command_error stg branch --cleanup 2>err &&
24 grep "Cannot clean up: the series still contains patches" err
27 test_expect_success
'Clone branch with patches' '
28 stg branch --clone foo2 &&
29 test "$(stg branch)" = "foo2" &&
30 test "$(stg series --noprefix --unapplied)" = "p0"
33 test_expect_success
'Force cleanup branch with patches' '
34 git config --get-regexp branch\\.foo2\\.stgit &&
35 stg branch --cleanup --force &&
36 test "$(stg series --noprefix --all)" = "" &&
37 command_error stg new -m p1 2>err &&
38 grep "branch not initialized" err &&
39 test_expect_code 1 git config --get-regexp branch\\.foo2\\.stgit
42 test_expect_success
'Commit patches' '
48 test_expect_success
'Invalid num args to cleanup' '
49 command_error stg branch --cleanup foo extra 2>err &&
50 grep "incorrect number of arguments" err
53 test_expect_success
'Cleanup current branch' '
54 stg branch --cleanup &&
55 test "$(stg branch)" = "foo" &&
56 command_error stg new -m p1 2>err &&
57 grep "branch not initialized" err
60 test_expect_success
'Re-initialize branch' '
64 test_expect_success
'Cleanup from another branch' '
66 stg branch --cleanup foo &&
67 test "$(stg branch)" = "master"