3 # Copyright (c) 2007 Karl Hasselström
6 test_description
='Test "stg new".'
11 'Initialize the StGIT repository' '
16 'Too many arguments' '
17 command_error stg new foo extra_arg 2>&1 |
18 grep -e "incorrect number of arguments"
22 'Create a named patch' '
23 stg new foo -m foobar &&
24 [ $(stg series --applied -c) -eq 1 ]
28 'Invalid patch name: space' '
29 command_error stg new "bad name" 2>&1 >/dev/null |
30 grep -e "Invalid patch name: \"bad name\""
34 'Invalid patch name: carat' '
35 command_error stg new "bad^name" 2>&1 >/dev/null |
36 grep -e "Invalid patch name: \"bad\^name\""
40 'Invalid patch name: empty' '
41 command_error stg new "" 2>&1 >/dev/null |
42 grep -e "Invalid patch name: \"\""
46 'Create a patch without giving a name' '
48 [ "$(echo $(stg top))" = "yo" ] &&
49 [ $(stg series --applied -c) -eq 2 ]
53 'Attempt to create patch with duplicate name' '
54 command_error stg new foo -m "duplicate foo" 2>&1 |
55 grep -e "foo: patch already exists"
59 'Attempt new with conflicts' '
61 echo "something" > file.txt &&
65 echo "something else" > file.txt &&
69 echo "something different" > file.txt &&
71 conflict stg push p1 &&
72 command_error stg new -m p3 2>&1 |
73 grep -e "Cannot create a new patch -- resolve conflicts first" &&
79 stg new --save-template new-tmpl.txt &&
80 test_path_is_file new-tmpl.txt
84 'New with patchdescr.tmpl' '
85 echo "Patch Description Template" > .git/patchdescr.tmpl &&
86 stg new templated-patch &&
87 stg show | grep "Patch Description Template"
91 'Patch with slash in name' '
92 stg new bar/foo -m "patch bar/foo"