b4: Make it work with sourcehut instead v1 PROPOSED

William Casarin: 1
 Make it work with sourcehut instead

 1 files changed, 2 insertions(+), 20 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~andir/nixpkgs-dev/patches/20097/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH b4] Make it work with sourcehut instead Export this patch

Signed-off-by: William Casarin <jb55@jb55.com>

Hey guys,

There's a patch for b4 that allows it to work with sourcehut


  $ b4 am 20210206202618.32583-1-jb55@jb55.com
  Analyzing 2 messages in the thread
  Writing ./20210206_jb55_b4_init_at_0_6_2.mbx
    [PATCH] b4: init at 0.6.2
      + Reviewed-by: Xinglu Chen <public@yoctocell.xyz> (✓ DKIM/yoctocell.xyz)
  Total patches: 1
   Link: https://lists.sr.ht/~andir/nixpkgs-dev/%3C20210206202618.32583-1-jb55@jb55.com%3E

The b4 config I used was:

   # Where to look up threads by message id
   midmask = https://lists.sr.ht/~andir/nixpkgs-dev/%%3C%s%%3E/mbox
   # When recording Link: trailers, use this mask
   linkmask = https://lists.sr.ht/~andir/nixpkgs-dev/%%3C%s%%3E
This should make it easier to apply trailers directly from sourcehut


 b4/__init__.py | 22 ++--------------------
 1 file changed, 2 insertions(+), 20 deletions(-)

diff --git a/b4/__init__.py b/b4/__init__.py
index 32b5c02..4cf411d 100644
--- a/b4/__init__.py
@@ -5,7 +5,6 @@ import logging
import hashlib
import re
import sys
import gzip
import os
import fnmatch
import email.utils
@@ -2284,7 +2283,7 @@ def get_pi_thread_by_url(t_mbx_url, savefile, nocache=False):
    if resp.status_code != 200:
        logger.critical('Server returned an error: %s', resp.status_code)
        return None
    t_mbox = gzip.decompress(resp.content)
    t_mbox = resp.content
    if not len(t_mbox):
        logger.critical('No messages found for that query')
@@ -2302,26 +2301,9 @@ def get_pi_thread_by_msgid(msgid, savefile, useproject=None, nocache=False):
    qmsgid = urllib.parse.quote_plus(msgid)
    config = get_main_config()
    # Grab the head from lore, to see where we are redirected
    midmask = config['midmask'] % qmsgid
    loc = urllib.parse.urlparse(midmask)
    if useproject:
        projurl = '%s://%s/%s' % (loc.scheme, loc.netloc, useproject)
        logger.info('Looking up %s', midmask)
        session = get_requests_session()
        resp = session.head(midmask)
        if resp.status_code < 300 or resp.status_code > 400:
            logger.critical('That message-id is not known.')
            return None
        # Pop msgid from the end of the redirect
        chunks = resp.headers['Location'].rstrip('/').split('/')
        projurl = '/'.join(chunks[:-1])
    t_mbx_url = '%s/%s/t.mbox.gz' % (projurl, qmsgid)
    t_mbx_url = config['midmask'] % qmsgid
    logger.debug('t_mbx_url=%s', t_mbx_url)

    logger.critical('Grabbing thread from %s', projurl.split('://')[1])

    tmp_mbox = mkstemp('b4-lookup-mbox')[1]
    in_mbxf = get_pi_thread_by_url(t_mbx_url, tmp_mbox, nocache=nocache)
    if not in_mbxf: