3 test_description
="Test 'stg export'"
6 test_expect_success
'Initialize repo with patches' '
7 echo "foo" > foo.txt &&
9 git commit -m "initial" &&
11 for i in 1 2 3 4 5; do
12 echo "line $i" >> foo.txt &&
13 stg new -m "patch-$i" &&
18 test_expect_success
'Export to directory' '
19 stg export -d export1 &&
20 for i in 1 2 3 4 5; do
21 test_path_is_file export1/patch-$i
25 test_expect_success
'Reimport directory export' '
26 stg delete $(stg series --noprefix) &&
27 stg import -s export1/series &&
28 test "$(echo $(stg series --noprefix))" = \
29 "patch-1 patch-2 patch-3 patch-4 patch-5" &&
30 test "$(echo $(stg series -d --noprefix patch-1))" = "patch-1 # patch-1"
33 test_expect_success
'Export to stdout' '
34 stg export --stdout > export2.txt &&
35 head -n1 export2.txt |
36 grep -e "^----------------------------"
39 test_expect_success
'Export with none applied' '
41 command_error stg export --dir export3 2>err &&
42 grep -e "No patches applied" err &&
43 test_path_is_missing export3 &&
47 test_expect_success
'Export with dirty working tree' '
48 echo "another line" >> foo.txt &&
49 stg export -d export4 patch-1 2>err &&
50 grep -e "Warning: Local changes in the tree" err &&
51 test_path_is_file export4/series &&
52 test_path_is_file export4/patch-1 &&
56 test_expect_success
'Use custom template' '
57 echo "%(authemail)s -- %(shortdescr)s" > template &&
58 stg export -t template -p patch-1 &&
59 grep -e "^author@example.com -- patch-1" patches-master/patch-1.patch
62 test_expect_success
'Export numbered patches with custom extension' '
63 stg export -d export5 -n -e mydiff patch-1 patch-2 &&
64 test_path_is_file export5/01-patch-1.mydiff &&
65 test_path_is_file export5/02-patch-2.mydiff &&
66 grep -e "02-patch-2\.mydiff" export5/series
69 test_expect_success
'Export series with empty patch' '
71 stg export -d export6 &&
72 test_path_is_file export6/patch-6 &&
73 stg delete $(stg series --noprefix) &&
74 stg import -s export6/series