diff options
| author | David Bremner <david@tethera.net> | 2026-01-25 07:56:38 +0900 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2026-02-16 07:24:18 +0900 |
| commit | c4c0843d8fed39d4d7da6be493248f75d0c0d706 (patch) | |
| tree | fccc1200f62566d47a358369be153fffc570545d /test/make-export.py | |
| parent | cfc4af0e2bdf8f82ad14342baa6578d4dd366cd9 (diff) | |
cli/git-remote: add export command
Two (sub)features are stubbed out in this initial implementation:
deleting messages (as opposed to tags), and missing messages. There
are two corresponding tests marked as broken in T860-git-remote.sh.
A third test passes with the stub, which is maybe not ideal, but at
least it acts as a regression test.
Diffstat (limited to 'test/make-export.py')
| -rw-r--r-- | test/make-export.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/make-export.py b/test/make-export.py new file mode 100644 index 00000000..0e6a1141 --- /dev/null +++ b/test/make-export.py @@ -0,0 +1,44 @@ +# generate a test input for the 'export' subcommand of the +# git-remote-notmuch helper + +from notmuch2 import Database +from time import time +from hashlib import sha1 + +def hexencode(str): + output_charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-_@=.," + out = "" + for char in str: + if not char in output_charset: + out+= f"%{ord(char):x}" + else: + out+= char + return out + +db = Database(config=Database.CONFIG.SEARCH) + +count=1 +print("export") +mark={} + +for msg in db.messages(""): + mark[msg.messageid]=count + blob="" + for tag in msg.tags: + blob += f"{tag}\n" + print (f"blob\nmark :{count}"); + print (f"data {len(blob)}\n{blob}") + count=count+1 + +print (f"\ncommit refs/heads/master\nmark :{count+1}") +ctime = int(time()) +print (f"author Notmuch Test Suite <notmuch@example.com> {ctime} +0000") +print (f"committer Notmuch Test Suite <notmuch@example.com> {ctime} +0000") +print (f"data 8\nignored") + +for msg in db.messages(""): + digest = sha1(msg.messageid.encode('utf8')).hexdigest() + filename = hexencode(msg.messageid) + print (f"M 100644 :{mark[msg.messageid]} _notmuch_metadata/{digest[0:2]}/{digest[2:4]}/{filename}/tags") + +print("\ndone\n") |
