Regression test for "stg mail"
[stgit] / t / t1900-mail.sh
1 #!/bin/sh
2 # Copyright (c) 2006 Karl Hasselström
3 test_description='Test the mail command'
4 . ./test-lib.sh
5
6 test_expect_success \
7 'Initialize the StGIT repository' \
8 '
9 for i in 1 2 3 4 5; do
10 touch foo.txt &&
11 echo "line $i" >> foo.txt &&
12 git add foo.txt &&
13 git commit -a -m "Patch $i"
14 done &&
15 stg init &&
16 stg uncommit -n 5 foo
17 '
18
19 test_expect_success \
20 'Put all the patches in an mbox' \
21 'stg mail --to="Inge Ström <inge@example.com>" -a -m \
22 -t ../../templates/patchmail.tmpl > mbox0'
23
24 test_expect_success \
25 'Import the mbox and compare' \
26 '
27 t1=$(git cat-file -p $(stg id) | grep ^tree)
28 stg pop -a &&
29 stg import -M mbox0 &&
30 t2=$(git cat-file -p $(stg id) | grep ^tree) &&
31 [ "$t1" == "$t2" ]
32 '
33
34 test_done