From 1eb413da0dc9ca57793e6daec03b6f373151eaff Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 21 Nov 2019 14:27:51 -0700 Subject: notmuch-extract-patch: tolerate text in Subject: before [PATCH nn/mm] Signed-off-by: Sean Whitton --- debian/changelog | 9 +++++++++ mailscripts.el | 2 +- notmuch-extract-patch/notmuch-extract-patch | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 9f6a0d1..773e78f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +mailscripts (0.15-1) UNRELEASED; urgency=medium + + * notmuch-extract-patch: do not require that '[PATCH nn/mm]' appear + right at the beginning of the Subject: field. + With mail forwarded by the Debian BTS, 'Bug#nnnnnn: ' is prepended to + the Subject: field. + + -- Sean Whitton Thu, 21 Nov 2019 14:23:15 -0700 + mailscripts (0.14-1) unstable; urgency=medium * email-print-mime-structure: add bash completion (Closes: #944434). diff --git a/mailscripts.el b/mailscripts.el index 916aec8..fa4c733 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -1,7 +1,7 @@ ;;; mailscripts.el --- functions to access tools in the mailscripts package ;; Author: Sean Whitton -;; Version: 0.13 +;; Version: 0.15 ;; Package-Requires: (notmuch projectile) ;; Copyright (C) 2018, 2019 Sean Whitton diff --git a/notmuch-extract-patch/notmuch-extract-patch b/notmuch-extract-patch/notmuch-extract-patch index 4cfda4c..7eff31a 100755 --- a/notmuch-extract-patch/notmuch-extract-patch +++ b/notmuch-extract-patch/notmuch-extract-patch @@ -56,7 +56,7 @@ def has_reroll_count(msg, v): or (v == 1 and not any(entry[0] == 'v' for entry in subject_prefix)) def get_subject_prefix(s): - match = re.search(r'''^\[(.*PATCH.*)\]''', s) + match = re.search(r'''\[(.*PATCH.*)\]''', s) if match: return match.group(1).split() -- cgit v1.2.3 From 8822515602bedcc4ce5b6a2428a2e506fdc0bf6d Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 21 Nov 2019 14:30:43 -0700 Subject: handle notmuch-show-thread-id not actually containing a thread ID Signed-off-by: Sean Whitton --- debian/changelog | 2 ++ mailscripts.el | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 773e78f..69102fd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,8 @@ mailscripts (0.15-1) UNRELEASED; urgency=medium right at the beginning of the Subject: field. With mail forwarded by the Debian BTS, 'Bug#nnnnnn: ' is prepended to the Subject: field. + * mailscripts.el: handle situation in which notmuch-show-thread-id + contains an arbitrary search query rather than the thread ID. -- Sean Whitton Thu, 21 Nov 2019 14:23:15 -0700 diff --git a/mailscripts.el b/mailscripts.el index fa4c733..9c51f73 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -68,7 +68,17 @@ particular, this Emacs Lisp function supports passing only entire threads to the notmuch-extract-patch(1) command." (interactive "Dgit repo: \nsbranch name (or leave blank to apply to current HEAD): \np") - (let ((thread-id notmuch-show-thread-id) + (let ((thread-id + ;; If `notmuch-show' was called with a notmuch query rather + ;; than a thread ID, as `org-notmuch-follow-link' in + ;; org-notmuch.el does, then `notmuch-show-thread-id' might + ;; be an arbitrary notmuch query instead of a thread ID. We + ;; need to wrap such a query in thread:{} before passing it + ;; to notmuch-extract-patch(1), or we might not get a whole + ;; thread extracted (e.g. if the query is just id:foo) + (if (string= (substring notmuch-show-thread-id 0 7) "thread:") + notmuch-show-thread-id + (concat "thread:{" notmuch-show-thread-id "}"))) (default-directory (expand-file-name repo))) (mailscripts--check-out-branch branch) (shell-command -- cgit v1.2.3 From 284392c2f70a65616af65f70575c6abe4b389288 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 21 Nov 2019 15:20:25 -0700 Subject: notmuch-extract-patch: strip text in Subject: before '[PATCH nn/mm]' Signed-off-by: Sean Whitton --- debian/changelog | 9 +++++---- notmuch-extract-patch/notmuch-extract-patch | 10 ++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/debian/changelog b/debian/changelog index 69102fd..7036481 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,10 @@ mailscripts (0.15-1) UNRELEASED; urgency=medium - * notmuch-extract-patch: do not require that '[PATCH nn/mm]' appear - right at the beginning of the Subject: field. - With mail forwarded by the Debian BTS, 'Bug#nnnnnn: ' is prepended to - the Subject: field. + * notmuch-extract-patch: when checking the reroll count, do not require + that '[PATCH nn/mm]' appear right at the beginning of the subject. + * notmuch-extract-patch: strip text in Subject: before '[PATCH nn/mm]' + to avoid it getting into the commit message. + E.g. the Debian BTS prepends 'Bug#nnnnnn: ' to the Subject: field. * mailscripts.el: handle situation in which notmuch-show-thread-id contains an arbitrary search query rather than the thread ID. diff --git a/notmuch-extract-patch/notmuch-extract-patch b/notmuch-extract-patch/notmuch-extract-patch index 7eff31a..d67e542 100755 --- a/notmuch-extract-patch/notmuch-extract-patch +++ b/notmuch-extract-patch/notmuch-extract-patch @@ -60,6 +60,15 @@ def get_subject_prefix(s): if match: return match.group(1).split() +# if Subject: contains [PATCH nn/mm] then any text before that should +# be stripped, as it should not form part of the commit message. (The +# debbugs system prepends 'Bug#nnnnnn: ') +def munge_subject(msg): + match = re.search(r'''\[(.*PATCH.*)\].*$''', msg['subject']) + if match: + del msg['subject'] + msg['subject'] = match.group(0) + def main(): try: opts, query = getopt.getopt(sys.argv[1:], "v:", ["reroll-count="]) @@ -81,6 +90,7 @@ def main(): for m in in_mb: if is_git_patch(m) and has_reroll_count(m, reroll_count): sys.stderr.write(m['subject']+"\n") + munge_subject(m) out_mb.add(m) out_mb.flush() print(open(out_mb_file.name).read()) -- cgit v1.2.3 From 8ec259d84c40cd9832869edfab901ce4d48c7179 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Thu, 21 Nov 2019 14:30:20 +0800 Subject: email-print-mime-structure: prepare for multiple forms of decryption As we prepare for S/MIME decryption, we want to identify pgp decryption as just one type of decryption. There is no functional change here. Signed-off-by: Daniel Kahn Gillmor Acked-by: Sean Whitton --- email-print-mime-structure | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/email-print-mime-structure b/email-print-mime-structure index 4f165b1..27fb532 100755 --- a/email-print-mime-structure +++ b/email-print-mime-structure @@ -78,15 +78,16 @@ class MimePrinter(object): nbytes = len(payload) print(f'{prefix}{z.get_content_type()}{cset}{disposition}{fname} {nbytes:d} bytes') - try_decrypt:bool = self.args.pgpkey or self.args.use_gpg_agent + cryptopayload:Optional[Message] = None + ciphertext:Union[List[Message],str,bytes,None] = None + try_pgp_decrypt:bool = self.args.pgpkey or self.args.use_gpg_agent - if try_decrypt and \ + if try_pgp_decrypt and \ (parent is not None) and \ (parent.get_content_type().lower() == 'multipart/encrypted') and \ (str(parent.get_param('protocol')).lower() == 'application/pgp-encrypted') and \ (num == 2): - cryptopayload:Optional[Message] = None - ciphertext:Union[List[Message],str,bytes,None] = z.get_payload() + ciphertext = z.get_payload() if not isinstance(ciphertext, str): logging.warning('encrypted part was not a leaf mime part somehow') return @@ -97,6 +98,8 @@ class MimePrinter(object): if cryptopayload is None: logging.warning(f'Unable to decrypt') return + + if cryptopayload is not None: newprefix = prefix[:-3] + ' ' print(f'{newprefix}↧ (decrypts to)') self.print_tree(cryptopayload, newprefix + '└', z, 0) -- cgit v1.2.3 From 0f4661cde91646c0481d00413d1188cf538829d5 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 21 Nov 2019 15:31:30 -0700 Subject: release mailscripts 0.15 (-1 to Debian unstable) Signed-off-by: Sean Whitton --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 7036481..10d3f6a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -mailscripts (0.15-1) UNRELEASED; urgency=medium +mailscripts (0.15-1) unstable; urgency=medium * notmuch-extract-patch: when checking the reroll count, do not require that '[PATCH nn/mm]' appear right at the beginning of the subject. @@ -8,7 +8,7 @@ mailscripts (0.15-1) UNRELEASED; urgency=medium * mailscripts.el: handle situation in which notmuch-show-thread-id contains an arbitrary search query rather than the thread ID. - -- Sean Whitton Thu, 21 Nov 2019 14:23:15 -0700 + -- Sean Whitton Thu, 21 Nov 2019 15:31:18 -0700 mailscripts (0.14-1) unstable; urgency=medium -- cgit v1.2.3