From nobody Sat Feb 6 21:51:16 2021 Authentication-Results: mail-b.sr.ht; dkim=none Received: from jb55.com (jb55.com [45.79.91.128]) by mail-b.sr.ht (Postfix) with ESMTPS id F28B211F018 for <~andir/nixpkgs-dev@lists.sr.ht>; Sat, 6 Feb 2021 21:51:15 +0000 (UTC) Received: from jb55.com (S010660e327dca171.vc.shawcable.net [24.84.152.187]) by jb55.com (OpenSMTPD) with ESMTPSA id e9512b6c (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Sat, 6 Feb 2021 21:52:21 +0000 (UTC) From: William Casarin To: ~andir/nixpkgs-dev@lists.sr.ht Cc: William Casarin Subject: [PATCH b4] Make it work with sourcehut instead Date: Sat, 6 Feb 2021 13:51:11 -0800 Message-Id: <20210206215111.4767-1-jb55@jb55.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: William Casarin --- Hey guys, There's a patch for b4 that allows it to work with sourcehut Example: $ 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 (✓ 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: [b4] # 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 Cheers, Will 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 +++ b/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 resp.close() 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) - else: - 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]) - resp.close() - 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: -- 2.30.0