unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob e88fa6c9a49d48f64165593bc86fe4c0cbdbd950 5772 bytes (raw)
name: test/T860-git-remote.sh 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
 
#!/usr/bin/env bash
test_description='git-remote-notmuch'
. $(dirname "$0")/test-lib.sh || exit 1

notmuch_sanitize_git() {
    sed 's/^committer \(.*\) \(<[^>]*>\) [1-9][0-9]* [-+][0-9]*/committer \1 \2 TIMESTAMP TIMEZONE/'
}

add_email_corpus

mkdir repo

git_tmp=$(mktemp -d gitXXXXXXXX)

run_helper () {
    env -u NOTMUCH_CONFIG GIT_DIR=${git_tmp} git-remote-notmuch dummy-alias "?config=${NOTMUCH_CONFIG}"
}

export GIT_COMMITTER_NAME="Notmuch Test Suite"
export GIT_COMMITTER_EMAIL="notmuch@example.com"
export GIT_REMOTE_NM_DEBUG="s"
export GIT_REMOTE_NM_LOG=grn-log.txt
EXPECTED=$NOTMUCH_SRCDIR/test/git-remote.expected-output
MAKE_EXPORT_PY=$NOTMUCH_SRCDIR/test/make-export.py

TAG_FILE="87/b1/4EFC743A.3060609@april.org/tags"

test_begin_subtest 'capabilities'
echo capabilities | run_helper > OUTPUT
cat <<EOF > EXPECTED
import
export
refspec refs/heads/*:refs/notmuch/*

EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest 'list'
echo list | run_helper > OUTPUT
cat <<EOF > EXPECTED
? refs/heads/master

EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest 'import writes lastmod file'
echo import | run_helper dummy-alias dummy-url > /dev/null
lastmod=$(notmuch count --lastmod '*' | cut -f2-)
test_expect_equal "${lastmod}" "$(cat < ${git_tmp}/notmuch/lastmod)"

# note that this test must not be the first time import is run,
# because it depends on the lastmod file
test_begin_subtest 'import produces expected output'
echo import | run_helper | notmuch_sanitize_git > OUTPUT
test_expect_equal_file $EXPECTED/default.import OUTPUT

test_begin_subtest "clone notmuch://"
test_expect_success "git clone notmuch:// $(mktemp -d cloneXXXXXX)"

test_begin_subtest "clone notmuch://?config=notmuch-config"
test_expect_success "git clone notmuch://?config=notmuch-config $(mktemp -d cloneXXXXXX)"

test_begin_subtest "clone notmuch://?profile=default"
test_expect_success "git clone notmuch://?profile=default $(mktemp -d cloneXXXXXX)"

test_begin_subtest "clone notmuch://?config=notmuch-config&profile=default"
test_expect_success "git clone notmuch://?config=notmuch-config\&profile=default $(mktemp -d cloneXXXXXX)"

test_begin_subtest 'clone notmuch://`pwd`/mail'
test_expect_success "env -u NOTMUCH_CONFIG git clone notmuch://`pwd`/mail $(mktemp -d cloneXXXXXX)"

test_begin_subtest 'clone notmuch://`pwd`/mail/?config=`pwd`/notmuch-config'
test_expect_success "env -u NOTMUCH_CONFIG git clone notmuch://`pwd`/mail?config=`pwd`/notmuch-config $(mktemp -d cloneXXXXXX)"

test_begin_subtest 'clone notmuch://.../mail/?config=.../notmuch-config&profile=default'
test_expect_success "env -u NOTMUCH_CONFIG git clone notmuch://`pwd`/mail/?config=`pwd`/notmuch-config\&profile=default $(mktemp -d clone XXX)"

test_begin_subtest 'clone notmuch://?path=.../mail/&config=.../notmuch-config&profile=default'
test_expect_success "env -u NOTMUCH_CONFIG git clone notmuch://?path=`pwd`/mail\&config=notmuch-config\&profile=default $(mktemp -d cloneXXXXXX)"

test_begin_subtest "clone notmuch::"
test_expect_success "git clone notmuch:: $(mktemp -d cloneXXXXXX)"

test_begin_subtest 'clone notmuch::`pwd`/mail'
test_expect_success "env -u NOTMUCH_CONFIG git clone notmuch::`pwd`/mail $(mktemp -d cloneXXXXXX)"

test_begin_subtest 'clone notmuch::`pwd`/mail?config=`pwd`/notmuch-config'
test_expect_success "env -u NOTMUCH_CONFIG git clone notmuch::`pwd`/mail?config=`pwd`/notmuch-config $(mktemp -d cloneXXXXXX)"

test_begin_subtest "clone has every message"
git clone notmuch:: repo
find repo -name tags -type f | sed -e s,repo/../../,id:, -e s,/tags$,, | sort > OUTPUT
notmuch search --output=messages '*' | sort > EXPECTED
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "pull get new tag"
notmuch tag +zznew -- id:4EFC743A.3060609@april.org
git -C repo pull
cat<<EOF >EXPECTED
inbox
unread
zznew
EOF
test_expect_equal_file EXPECTED repo/$TAG_FILE

test_begin_subtest "pull sees deletion"
notmuch tag -unread -- id:4EFC743A.3060609@april.org
git -C repo pull
cat<<EOF >EXPECTED
inbox
zznew
EOF
test_expect_equal_file EXPECTED repo/$TAG_FILE

test_begin_subtest 'export runs'
run_helper <<EOF | notmuch_sanitize_git > OUTPUT
export
blob
mark :1
data 10
tag1
tag2

commit refs/heads/master
mark :2
author Notmuch Test Suite <notmuch@example.com> 1234 +0000
committer Notmuch Test Suite <notmuch@example.com> 1234 +0000
data 8
ignored
M 100644 :1 $TAG_FILE

done

EOF
cat <<EOF > EXPECTED
ok refs/heads/master

EOF
test_expect_equal_file EXPECTED OUTPUT

# this test depends on the previous one
test_begin_subtest 'export modifies database'
notmuch dump id:4EFC743A.3060609@april.org | tail -n 1 > OUTPUT
cat <<EOF > EXPECTED
+tag1 +tag2 -- id:4EFC743A.3060609@april.org
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest 'restore via export'
notmuch dump > BEFORE
python3 $MAKE_EXPORT_PY > export.in
notmuch tag +transient -- id:4EFC743A.3060609@april.org
run_helper < export.in > OUTPUT
notmuch dump id:4EFC743A.3060609@april.org | tail -n 1 > OUTPUT
cat <<EOF > EXPECTED
+tag1 +tag2 -- id:4EFC743A.3060609@april.org
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "push updates database"
git -C repo push origin master
notmuch dump id:4EFC743A.3060609@april.org | tail -n 1 > OUTPUT
cat <<EOF > EXPECTED
+tag1 +tag2 -- id:4EFC743A.3060609@april.org
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "adding tag via repo"
cat<<EOF >repo/$TAG_FILE
tag1
tag2
tag3
EOF
git -C repo add $TAG_FILE
git -C repo commit -m 'testing push'
git -C repo push origin master
notmuch dump id:4EFC743A.3060609@april.org | tail -n 1 > OUTPUT
cat <<EOF > EXPECTED
+tag1 +tag2 +tag3 -- id:4EFC743A.3060609@april.org
EOF
test_expect_equal_file EXPECTED OUTPUT

test_done

debug log:

solving 014ffc2b ...
found 014ffc2b in https://yhetil.org/notmuch/20240908113937.286108-5-david@tethera.net/
found 97b8e4f9 in https://yhetil.org/notmuch/20240908113937.286108-4-david@tethera.net/
found 1a087611 in https://yhetil.org/notmuch/20240908113937.286108-3-david@tethera.net/

applying [1/3] https://yhetil.org/notmuch/20240908113937.286108-3-david@tethera.net/
diff --git a/test/T860-git-remote.sh b/test/T860-git-remote.sh\r
new file mode 100755\r
index 00000000..1a087611\r


applying [2/3] https://yhetil.org/notmuch/20240908113937.286108-4-david@tethera.net/
diff --git a/test/T860-git-remote.sh b/test/T860-git-remote.sh
index 1a087611..97b8e4f9 100755


applying [3/3] https://yhetil.org/notmuch/20240908113937.286108-5-david@tethera.net/
diff --git a/test/T860-git-remote.sh b/test/T860-git-remote.sh
index 97b8e4f9..014ffc2b 100755

3:7: trailing whitespace.
#!/usr/bin/env bash\r
3:8: trailing whitespace.
test_description='git-remote-notmuch'\r
3:9: trailing whitespace.
. $(dirname "$0")/test-lib.sh || exit 1\r
3:10: trailing whitespace.
\r
3:11: trailing whitespace.
notmuch_sanitize_git() {\r
Checking patch test/T860-git-remote.sh...
Applied patch test/T860-git-remote.sh cleanly.
Checking patch test/T860-git-remote.sh...
Applied patch test/T860-git-remote.sh cleanly.
Checking patch test/T860-git-remote.sh...
Applied patch test/T860-git-remote.sh cleanly.
warning: squelched 41 whitespace errors
warning: 46 lines add whitespace errors.

index at:
100755 e88fa6c9a49d48f64165593bc86fe4c0cbdbd950	test/T860-git-remote.sh

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).