]> git.cworth.org Git - notmuch/blob - test/T850-git.sh
72091b5655db0c0c6a9c48ff09061eee8041d5eb
[notmuch] / test / T850-git.sh
1 #!/usr/bin/env bash
2 test_description='"notmuch git" to save and restore tags'
3 . $(dirname "$0")/test-lib.sh || exit 1
4
5 if [ $NOTMUCH_HAVE_SFSEXP -ne 1 ]; then
6     printf "Skipping due to missing sfsexp library\n"
7     test_done
8 fi
9
10 add_email_corpus
11
12 git config --global user.email notmuch@example.org
13 git config --global user.name  "Notmuch Test Suite"
14
15 test_begin_subtest "init"
16 test_expect_success "notmuch git -p '' -C remote.git init"
17
18 test_begin_subtest "clone"
19 test_expect_success "notmuch git -p '' -C tags.git clone remote.git"
20
21 test_begin_subtest "commit"
22 notmuch git -C tags.git -p '' commit
23 git -C tags.git ls-tree -r --name-only HEAD | xargs dirname | sort -u | sed s,tags/,id:, > OUTPUT
24 notmuch search --output=messages '*' | sort > EXPECTED
25 test_expect_equal_file_nonempty EXPECTED OUTPUT
26
27 test_begin_subtest "commit, with quoted tag"
28 notmuch git -C clone2.git -p '' clone tags.git
29 git -C clone2.git ls-tree -r --name-only HEAD | grep /inbox > BEFORE
30 notmuch tag '+"quoted tag"' '*'
31 notmuch git -C clone2.git -p '' commit
32 notmuch tag '-"quoted tag"' '*'
33 git -C clone2.git ls-tree -r --name-only HEAD | grep /inbox > AFTER
34 test_expect_equal_file_nonempty BEFORE AFTER
35
36 test_begin_subtest "checkout"
37 notmuch dump > BEFORE
38 notmuch tag -inbox '*'
39 notmuch git -C tags.git -p '' checkout
40 notmuch dump > AFTER
41 test_expect_equal_file_nonempty BEFORE AFTER
42
43 test_begin_subtest "archive"
44 notmuch git -C tags.git -p '' archive | tar tf - | \
45     grep 20091117190054.GU3165@dottiness.seas.harvard.edu | sort > OUTPUT
46 cat <<EOF > EXPECTED
47 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/
48 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/inbox
49 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/signed
50 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/unread
51 EOF
52 notmuch git -C tags.git -p '' checkout
53 test_expect_equal_file EXPECTED OUTPUT
54
55 test_begin_subtest "status"
56 notmuch tag +test id:20091117190054.GU3165@dottiness.seas.harvard.edu
57 notmuch git -C tags.git -p '' status > OUTPUT
58 cat <<EOF > EXPECTED
59 A       20091117190054.GU3165@dottiness.seas.harvard.edu        test
60 EOF
61 notmuch git -C tags.git -p '' checkout
62 test_expect_equal_file EXPECTED OUTPUT
63
64 test_begin_subtest "fetch"
65 notmuch tag +test2 id:20091117190054.GU3165@dottiness.seas.harvard.edu
66 notmuch git -C remote.git -p '' commit
67 notmuch tag -test2 id:20091117190054.GU3165@dottiness.seas.harvard.edu
68 notmuch git -C tags.git -p '' fetch
69 notmuch git -C tags.git -p '' status > OUTPUT
70 cat <<EOF > EXPECTED
71  a      20091117190054.GU3165@dottiness.seas.harvard.edu        test2
72 EOF
73 notmuch git -C tags.git -p '' checkout
74 test_expect_equal_file EXPECTED OUTPUT
75
76 test_begin_subtest "merge"
77 notmuch git -C tags.git -p '' merge
78 notmuch dump id:20091117190054.GU3165@dottiness.seas.harvard.edu | grep -v '^#' > OUTPUT
79 cat <<EOF > EXPECTED
80 +inbox +signed +test2 +unread -- id:20091117190054.GU3165@dottiness.seas.harvard.edu
81 EOF
82 test_expect_equal_file EXPECTED OUTPUT
83
84 test_begin_subtest "push"
85 notmuch tag +test3 id:20091117190054.GU3165@dottiness.seas.harvard.edu
86 notmuch git -C tags.git -p '' commit
87 notmuch tag -test3 id:20091117190054.GU3165@dottiness.seas.harvard.edu
88 notmuch git -C tags.git -p '' push
89 notmuch git -C remote.git -p '' checkout
90 notmuch dump id:20091117190054.GU3165@dottiness.seas.harvard.edu | grep -v '^#' > OUTPUT
91 cat <<EOF > EXPECTED
92 +inbox +signed +test2 +test3 +unread -- id:20091117190054.GU3165@dottiness.seas.harvard.edu
93 EOF
94 test_expect_equal_file EXPECTED OUTPUT
95
96 test_begin_subtest "environment passed through when run as 'notmuch git'"
97 env NOTMUCH_GIT_DIR=foo NOTMUCH_GIT_PREFIX=bar NOTMUCH_PROFILE=default notmuch git -C tags.git -p '' -ldebug status |& \
98     grep '^env ' | notmuch_dir_sanitize > OUTPUT
99 cat <<EOF > EXPECTED
100 env NOTMUCH_GIT_DIR = foo
101 env NOTMUCH_GIT_PREFIX = bar
102 env NOTMUCH_PROFILE = default
103 env NOTMUCH_CONFIG = CWD/notmuch-config
104 EOF
105 test_expect_equal_file EXPECTED OUTPUT
106
107 test_done