Release 0.19
[stgit.git] / t / t4300-export.sh
blob6241e945e371d6c1647a141384efd4faa9d7b511
1 #!/bin/sh
3 test_description="Test 'stg export'"
4 . ./test-lib.sh
6 test_expect_success 'Initialize repo with patches' '
7 echo "foo" > foo.txt &&
8 git add foo.txt &&
9 git commit -m "initial" &&
10 stg init &&
11 for i in 1 2 3 4 5; do
12 echo "line $i" >> foo.txt &&
13 stg new -m "patch-$i" &&
14 stg refresh
15 done
18 test_expect_success 'Export to directory' '
19 stg export -d export1 &&
20 for i in 1 2 3 4 5; do
21 test -e export1/patch-$i
22 done
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' '
40 stg pop -a &&
41 command_error stg export --dir export3 2>&1 |
42 grep -e "No patches applied" &&
43 test ! -e export3 &&
44 stg push -a
47 test_expect_success 'Export with dirty working tree' '
48 echo "another line" >> foo.txt &&
49 stg export -d export4 patch-1 2>&1 |
50 grep -e "Warning: Local changes in the tree" &&
51 test -e export4/series &&
52 test -e export4/patch-1 &&
53 git checkout foo.txt
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 -e export5/01-patch-1.mydiff &&
65 test -e export5/02-patch-2.mydiff &&
66 grep -e "02-patch-2\.mydiff" export5/series
69 test_done