unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: Re: [PATCH v2 2/4] cli: start remote helper for git.
Date: Thu, 03 Oct 2024 08:26:53 -0300	[thread overview]
Message-ID: <87r08x4ebm.fsf@tethera.net> (raw)
In-Reply-To: <87ttdt4eiq.fsf@tethera.net>

[-- Attachment #1: Type: text/plain, Size: 586 bytes --]

David Bremner <david@tethera.net> writes:

> David Bremner <david@tethera.net> writes:
>
>> +EXPECTED=$NOTMUCH_SRCDIR/test/git-remote.expected-output
>> +MAKE_EXPORT_PY=$NOTMUCH_SRCDIR/test/make-export.py
>
> I see I lost the script make-export.py going from v1 to v2. I will
> re-roll the series to include it, but I want try a refactor that puts
> the URL parsing into the library in a new notmuch_database_open_url
> function that can be re-used by e.g. neomutt (hopefully).

Ugh. And that version of the script was broken by screen scraping from
notmuch. This one is hopefully ok.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: make-export.py --]
[-- Type: text/x-python, Size: 1227 bytes --]

# 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]} {digest[0:2]}/{digest[2:4]}/{filename}/tags")

print("\ndone\n")

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



  reply	other threads:[~2024-10-03 11:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-08 11:27 David Bremner
2024-09-08 11:27 ` [PATCH v2 1/4] util: refactor sync_dir and mkdir_recursive David Bremner
2024-09-08 11:27 ` [PATCH v2 2/4] cli: start remote helper for git David Bremner
2024-10-03 11:22   ` David Bremner
2024-10-03 11:26     ` David Bremner [this message]
2024-09-08 11:27 ` [PATCH v2 3/4] cli/git-remote: add import command David Bremner
2024-09-08 11:27 ` [PATCH v2 4/4] cli/git-remote: add export command David Bremner
2024-09-08 12:07 ` git-remote-notmuch v2 David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r08x4ebm.fsf@tethera.net \
    --to=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).