From 784505e0dfaea9b4ac88c900734120bb947e7375 Mon Sep 17 00:00:00 2001 From: Robbie Harwood Date: Fri, 27 Mar 2020 13:46:42 -0400 Subject: imap-dl: Fix failure when python3-gssapi isn't installed The type annotation of the SecurityContext in GSSAPI_helper causes python to actually use the gssapi object, which is None when python3-gssapi isn't present. Work around this by making the class definition contingent on the presence of python3-gssapi. Signed-off-by: Robbie Harwood --- imap-dl | 68 +++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/imap-dl b/imap-dl index 5a8494c..a644549 100755 --- a/imap-dl +++ b/imap-dl @@ -95,39 +95,41 @@ def auth_builtin(username:str, imap:imaplib.IMAP4_SSL, if resp[0] != 'OK': raise Exception(f'login failed with {resp} as user {username} on {server}') -# imaplib auth methods need to be in the form of callables, and they all -# requre both additional parameters and storage beyond what the function -# interface provides. -class GSSAPI_handler(): - gss_vc:gssapi.SecurityContext - username:str - - def __init__(self, server:str, username:str) -> None: - name = gssapi.Name(f'imap@{server}', gssapi.NameType.hostbased_service) - self.gss_vc = gssapi.SecurityContext(usage="initiate", name=name) - self.username = username - - def __call__(self, token:Optional[bytes]) -> bytes: - if token == b"": - token = None - if not self.gss_vc.complete: - response = self.gss_vc.step(token) - return response if response else b"" # type: ignore - elif token is None: - return b"" - - response = self.gss_vc.unwrap(token) - - # Preserve the "length" of the message we received, and set the first - # byte to one. If username is provided, it's next. - reply:List[int] = [] - reply[0:4] = response.message[0:4] - reply[0] = 1 - if self.username: - reply[5:] = self.username.encode("utf-8") - - response = self.gss_vc.wrap(bytes(reply), response.encrypted) - return response.message if response.message else b"" # type: ignore +if gssapi: + # imaplib auth methods need to be in the form of callables, and they all + # requre both additional parameters and storage beyond what the function + # interface provides. + class GSSAPI_handler(): + gss_vc:gssapi.SecurityContext + username:str + + def __init__(self, server:str, username:str) -> None: + name = gssapi.Name(f'imap@{server}', + gssapi.NameType.hostbased_service) + self.gss_vc = gssapi.SecurityContext(usage="initiate", name=name) + self.username = username + + def __call__(self, token:Optional[bytes]) -> bytes: + if token == b"": + token = None + if not self.gss_vc.complete: + response = self.gss_vc.step(token) + return response if response else b"" # type: ignore + elif token is None: + return b"" + + response = self.gss_vc.unwrap(token) + + # Preserve the "length" of the message we received, and set the + # first byte to one. If username is provided, it's next. + reply:List[int] = [] + reply[0:4] = response.message[0:4] + reply[0] = 1 + if self.username: + reply[5:] = self.username.encode("utf-8") + + response = self.gss_vc.wrap(bytes(reply), response.encrypted) + return response.message if response.message else b"" # type: ignore def auth_gssapi(username:str, imap:imaplib.IMAP4_SSL, conf:configparser.ConfigParser, server:str) -> None: -- cgit v1.2.3 From 89c13d03c7fa3ea148b92707990aee2e2301fb2e Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 27 Mar 2020 11:51:26 -0700 Subject: changelog Signed-off-by: Sean Whitton --- debian/changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/debian/changelog b/debian/changelog index b44fabb..4e730d9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +mailscripts (0.20-1) UNRELEASED; urgency=medium + + * imap-dl: Fix failure when python3-gssapi isn't installed (Closes: #955011). + Thanks to Robbie Harwood for the patch. + + -- Sean Whitton Fri, 27 Mar 2020 11:50:27 -0700 + mailscripts (0.19-1) unstable; urgency=medium * notmuch-slurp-debbug: rework to use Mail::Box rather than shelling out -- cgit v1.2.3 From 6131b675e852077b65a588c636206ce0bf29ba27 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 1 May 2020 11:21:56 -0700 Subject: add mailing list info to CONTRIBUTING.md Signed-off-by: Sean Whitton --- CONTRIBUTING.rst | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ debian/changelog | 1 + 2 files changed, 55 insertions(+) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 707e2f6..0db4ab0 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -1,3 +1,57 @@ +Submitting patches +================== + +Thank you for your interest in contributing to this project! + +Please **do not** submit a pull request on GitHub. The repository +there is an automated mirror, and I don't develop using GitHub's +platform. + +Project mailing lists +===================== + +There are two low-volume project mailing lists, shared with some other +small free software projects: + +- sgo-software-announce -- + + + For release announcements. + +- sgo-software-discuss -- + + + For bug reports, posting patches, user questions and discussion. + +Please prepend ``[mailscripts]`` to the subject line of your e-mail, +and for patches, pass ``--subject-prefix="PATCH mailscripts"`` to +git-send-email(1). + +Posting to sgo-software-discuss +------------------------------- + +If you're not subscribed to the list, your posting will be held for +moderation; please be patient. + +Whether or not you're subscribed, chiark.greenend.org.uk has +aggressive antispam. If your messages aren't getting through, we can +easily add a bypass on chiark; please contact . + +If you don't want to deal with the mailing list and just want to send +patches, you should feel free to pass ``--to=spwhitton@spwhitton.name`` +to git-send-email(1). + +Alternatively, publish a git branch somewhere publically accessible (a +GitHub fork is fine) and write to me asking me to merge it. I may +convert your branch back into patches when sending you feedback :) + +Reporting bugs +============== + +Please read "How to Report Bugs Effectively" to ensure your bug report +constitutes a useful contribution to the project: + + Signing off your commits ======================== diff --git a/debian/changelog b/debian/changelog index 4e730d9..bee9aaf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ mailscripts (0.20-1) UNRELEASED; urgency=medium * imap-dl: Fix failure when python3-gssapi isn't installed (Closes: #955011). Thanks to Robbie Harwood for the patch. + * Add mailing list info to CONTRIBUTING.md. -- Sean Whitton Fri, 27 Mar 2020 11:50:27 -0700 -- cgit v1.2.3 From 5929201f46fa5b6661f5571453b69cbaf5e22b93 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Tue, 21 Apr 2020 13:26:07 +0200 Subject: notmuch-slurp-debbug: Fix ability to read configuration file Config::Tiny::read is a method meant to take two arguments, the second one being the configuration file name. Fixes regression introduced in f3a9d113fd89db152db9cd2f061fc8f7367f0fc9. Signed-off-by: intrigeri --- notmuch-slurp-debbug | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/notmuch-slurp-debbug b/notmuch-slurp-debbug index c187596..ad0db47 100755 --- a/notmuch-slurp-debbug +++ b/notmuch-slurp-debbug @@ -43,8 +43,7 @@ my $maildir; my $conf_r = $ENV{XDG_CONFIG_HOME} || catfile $ENV{HOME}, ".config"; my $conf_f = catfile $conf_r, "mailscripts", "notmuch-slurp-debbug"; if (-f $conf_f) { - my $Config = Config::Tiny::read($conf_f); - $maildir = $Config->{_}->{maildir}; + $maildir = Config::Tiny->new->read($conf_f)->{_}->{maildir}; } else { # default to where a lot of people have their inbox chomp(my $database_path = `notmuch config get database.path`); -- cgit v1.2.3 From 5d65ecfc4d331a676126c8a8b175eb95baeec1ba Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 1 May 2020 11:32:21 -0700 Subject: changelog Signed-off-by: Sean Whitton --- debian/changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/debian/changelog b/debian/changelog index bee9aaf..d6c2a7f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ mailscripts (0.20-1) UNRELEASED; urgency=medium * imap-dl: Fix failure when python3-gssapi isn't installed (Closes: #955011). Thanks to Robbie Harwood for the patch. + * notmuch-slurp-debbug: Fix reading configuration file (Closes: #958391). + Thanks to intrigeri for the patch. * Add mailing list info to CONTRIBUTING.md. -- Sean Whitton Fri, 27 Mar 2020 11:50:27 -0700 -- cgit v1.2.3 From f343a4e23e11ae97e6354ca9c4f91a60a0ea6563 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 1 May 2020 11:40:48 -0700 Subject: mailscripts.el: Change prompt "branch name" -> "new branch name" Signed-off-by: Sean Whitton --- debian/changelog | 5 +++++ mailscripts.el | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index d6c2a7f..c530300 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,11 @@ mailscripts (0.20-1) UNRELEASED; urgency=medium Thanks to Robbie Harwood for the patch. * notmuch-slurp-debbug: Fix reading configuration file (Closes: #958391). Thanks to intrigeri for the patch. + * mailscripts.el: + - Change prompt "branch name" -> "new branch name". + When the user inputs a branch name, it is used only to attempt the + creation of a new branch, but the old prompt suggests that inputting + an existing branch name would cause that branch to be checked out. * Add mailing list info to CONTRIBUTING.md. -- Sean Whitton Fri, 27 Mar 2020 11:50:27 -0700 diff --git a/mailscripts.el b/mailscripts.el index 0658c76..904a30a 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -67,7 +67,7 @@ See notmuch-extract-patch(1) manpage for limitations: in 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") + "Dgit repo: \nsnew branch name (or leave blank to apply to current HEAD): \nP") (let ((thread-id ;; If `notmuch-show' was called with a notmuch query rather ;; than a thread ID, as `org-notmuch-follow-link' in @@ -109,7 +109,7 @@ Patches are applied using git-am(1), so we only consider attachments with filenames which look like they were generated by git-format-patch(1)." (interactive - "Dgit repo: \nsbranch name (or leave blank to apply to current HEAD): ") + "Dgit repo: \nsnew branch name (or leave blank to apply to current HEAD): ") (with-current-notmuch-show-message (let ((default-directory (expand-file-name repo)) (mm-handle (mm-dissect-buffer))) -- cgit v1.2.3 From 238b98bc4245783134b30cbb2918a95d19dacee6 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 1 May 2020 11:51:32 -0700 Subject: mailscripts.el: Add mailscripts-detach-head-from-existing-branch Signed-off-by: Sean Whitton --- debian/changelog | 1 + mailscripts.el | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index c530300..5624a7d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,7 @@ mailscripts (0.20-1) UNRELEASED; urgency=medium When the user inputs a branch name, it is used only to attempt the creation of a new branch, but the old prompt suggests that inputting an existing branch name would cause that branch to be checked out. + - Add mailscripts-detach-head-from-existing-branch defcustom. * Add mailing list info to CONTRIBUTING.md. -- Sean Whitton Fri, 27 Mar 2020 11:50:27 -0700 diff --git a/mailscripts.el b/mailscripts.el index 904a30a..6fc8c69 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -34,6 +34,17 @@ E.g. `email/'." :type 'string :group 'mailscripts) +(defcustom mailscripts-detach-head-from-existing-branch nil + "Whether to detach HEAD before applying patches to an existing branch. + +This is useful if you want to manually review the result of +applying patches before updating any of your existing branches, +or for quick, ad hoc testing of a patch series. + +Note that this does not prevent the creation of new branches." + :type 'boolean + :group 'mailscripts) + ;;;###autoload (defun notmuch-slurp-debbug (bug &optional no-open) "Slurp Debian bug with bug number BUG and open the thread in notmuch. @@ -131,7 +142,9 @@ git-format-patch(1)." (mailscripts--projectile-repo-and-branch 'notmuch-extract-message-patches)) (defun mailscripts--check-out-branch (branch) - (unless (string= branch "") + (if (string= branch "") + (when mailscripts-detach-head-from-existing-branch + (call-process-shell-command "git checkout --detach")) (call-process-shell-command (format "git checkout -b %s" (shell-quote-argument -- cgit v1.2.3 From 24a97af734b300700463ff3532e796152f34aa64 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 1 May 2020 12:03:46 -0700 Subject: mailscripts.el: Set NO-STRICT-MIME argument of `mm-dissect-buffer' Signed-off-by: Sean Whitton --- debian/changelog | 2 ++ mailscripts.el | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 5624a7d..4e05959 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,8 @@ mailscripts (0.20-1) UNRELEASED; urgency=medium creation of a new branch, but the old prompt suggests that inputting an existing branch name would cause that branch to be checked out. - Add mailscripts-detach-head-from-existing-branch defcustom. + - notmuch-extract-message-patches: set NO-STRICT-MIME argument of + `mm-dissect-buffer' to enable extracting patches from more messages. * Add mailing list info to CONTRIBUTING.md. -- Sean Whitton Fri, 27 Mar 2020 11:50:27 -0700 diff --git a/mailscripts.el b/mailscripts.el index 6fc8c69..193ca5c 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -123,7 +123,7 @@ git-format-patch(1)." "Dgit repo: \nsnew branch name (or leave blank to apply to current HEAD): ") (with-current-notmuch-show-message (let ((default-directory (expand-file-name repo)) - (mm-handle (mm-dissect-buffer))) + (mm-handle (mm-dissect-buffer t))) (mailscripts--check-out-branch branch) (notmuch-foreach-mime-part (lambda (p) -- cgit v1.2.3 From 1d874bdc3e97853fbe6d3a7723e3bc82b1ce5df7 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 1 May 2020 12:19:47 -0700 Subject: fix filename Signed-off-by: Sean Whitton --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 4e05959..c6d4ba0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,7 +12,7 @@ mailscripts (0.20-1) UNRELEASED; urgency=medium - Add mailscripts-detach-head-from-existing-branch defcustom. - notmuch-extract-message-patches: set NO-STRICT-MIME argument of `mm-dissect-buffer' to enable extracting patches from more messages. - * Add mailing list info to CONTRIBUTING.md. + * Add mailing list info to CONTRIBUTING.rst. -- Sean Whitton Fri, 27 Mar 2020 11:50:27 -0700 -- cgit v1.2.3 From b3c1b1d32ae17899facbbf95784ef33d10654450 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 3 May 2020 10:43:48 -0700 Subject: add IRC channel Signed-off-by: Sean Whitton --- CONTRIBUTING.rst | 6 ++++++ debian/changelog | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 0db4ab0..7ef8682 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -45,6 +45,12 @@ Alternatively, publish a git branch somewhere publically accessible (a GitHub fork is fine) and write to me asking me to merge it. I may convert your branch back into patches when sending you feedback :) +IRC channel +=========== + +You can ask questions and discuss mailscripts in ``#notmuch`` on +server ``chat.freenode.net``. + Reporting bugs ============== diff --git a/debian/changelog b/debian/changelog index c6d4ba0..e084188 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,7 +12,7 @@ mailscripts (0.20-1) UNRELEASED; urgency=medium - Add mailscripts-detach-head-from-existing-branch defcustom. - notmuch-extract-message-patches: set NO-STRICT-MIME argument of `mm-dissect-buffer' to enable extracting patches from more messages. - * Add mailing list info to CONTRIBUTING.rst. + * Add mailing list & IRC channel info to CONTRIBUTING.rst. -- Sean Whitton Fri, 27 Mar 2020 11:50:27 -0700 -- cgit v1.2.3 From a9bc6cb4b501602db6947ba3ce90d040105151e0 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 4 May 2020 23:03:50 -0700 Subject: maildir-import-patch: Prepend "[PATCH fooproject imported]" Signed-off-by: Sean Whitton --- debian/changelog | 5 +++ maildir-import-patch | 97 +++++++++++++++++++++++++++------------------- maildir-import-patch.1.pod | 15 +++++++ 3 files changed, 78 insertions(+), 39 deletions(-) diff --git a/debian/changelog b/debian/changelog index e084188..53a9be1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,6 +12,11 @@ mailscripts (0.20-1) UNRELEASED; urgency=medium - Add mailscripts-detach-head-from-existing-branch defcustom. - notmuch-extract-message-patches: set NO-STRICT-MIME argument of `mm-dissect-buffer' to enable extracting patches from more messages. + * maildir-import-patch: Prepend "[PATCH fooproject imported]" to the + subject lines of patches, unless the user supplies a --subject-prefix + option to be passed on to git-format-patch(1). + This makes patches generated by this script more easily + distinguishable from patches really received by e-mail. * Add mailing list & IRC channel info to CONTRIBUTING.rst. -- Sean Whitton Fri, 27 Mar 2020 11:50:27 -0700 diff --git a/maildir-import-patch b/maildir-import-patch index f69a5e6..0147c49 100755 --- a/maildir-import-patch +++ b/maildir-import-patch @@ -1,8 +1,8 @@ -#!/usr/bin/python3 +#!/usr/bin/perl # maildir-import-patch -- import a git patch series into a maildir -# Copyright (C) 2019 Sean Whitton +# Copyright (C) 2019-2020 Sean Whitton # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,40 +17,59 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import os -import sys -import mailbox -import shutil -import subprocess -import tempfile - -def eprint(*args, **kwargs): - print(*args, file=sys.stderr, **kwargs) - -us = os.path.basename(sys.argv[0]) - -if len(sys.argv) < 2: - eprint(us + ": usage: " + us + " MAILDIR [git-format-patch(1) args]") - sys.exit(1) - -if not shutil.which("git"): - eprint(us + ": this script requires git to be installed") - sys.exit(1) - -dest_path = sys.argv[1] -dest = mailbox.Maildir(dest_path) - -cmd = [ - "git", "format-patch", - "--thread=shallow", "--no-cc", "--no-to", - "--stdout", -] -user_args = sys.argv[2:] - -with tempfile.NamedTemporaryFile() as fp: - subprocess.run(cmd + user_args, stdout=fp) - source = mailbox.mbox(fp.name) - dest.lock() - for message in source: - dest.add(message) - dest.close() +use strict; +use warnings; + +use Cwd; +use File::Basename; +use File::Temp (); +use File::Which; +use Git::Wrapper; +use List::MoreUtils "firstidx"; +use Mail::Box::Manager; + +my $us = basename $0; +my $maildir_dir = shift + or die "$us: usage: $us MAILDIR [git-format-patch(1) args]\n"; +which "git" or die "$us: this script requires git to be installed\n"; + +my $git = Git::Wrapper->new(getcwd); +my $toplevel; +{ + local $@; + eval { ($toplevel) = $git->rev_parse({ show_toplevel => 1 }) }; + $@ and die "$us: pwd doesn't look like a git repository ..\n"; +} +$toplevel =~ s/\.git$//; + +if (firstidx(sub { /^--subject-prefix/ }, @ARGV) == -1) { + my $subject_prefix; + my $rfc_idx = firstidx { /^--rfc$/ } @ARGV; + if ($rfc_idx == -1) { + $subject_prefix = "PATCH"; + } else { + $subject_prefix = "RFC PATCH"; + splice @ARGV, $rfc_idx, 1; + } + my ($project) = $git->config(qw|--local --get --default|, + basename($toplevel), "mailscripts.project-shortname"); + unshift @ARGV, "--subject-prefix=$subject_prefix $project imported"; +} + +my $mgr = Mail::Box::Manager->new; +my $maildir + = $mgr->open($maildir_dir, type => "maildir", access => "w", create => 1); + +my $mbox_file = File::Temp->new; +my $pid = fork; +die "fork() failed: $!" unless defined $pid; +unless ($pid) { + open STDOUT, ">&=", $mbox_file->fileno + or die "couldn't reopen child's STDOUT: $!"; + exec qw(git format-patch --no-cc --no-to --stdout --thread=shallow), @ARGV; +} +wait; +$mbox_file->close; + +my $mbox = $mgr->open($mbox_file->filename, type => "mbox", access => "r"); +$mgr->copyMessage($maildir, $_) for $mbox->messages; diff --git a/maildir-import-patch.1.pod b/maildir-import-patch.1.pod index a3ef110..7d728e4 100644 --- a/maildir-import-patch.1.pod +++ b/maildir-import-patch.1.pod @@ -34,6 +34,21 @@ Over in your MUA, you can then reply to each e-mail in the new thread generated by B, providing line-by-line feedback on Bob's work. +=head1 GIT CONFIGURATION KEYS + +=over 4 + +=item B + +Short identifier for the project to be prepended to the subject lines +of generated patches, like this: "[PATCH shortname imported]". If +unset, defaults to the name of the root directory of the repository. + +Ignored if any I<--subject-prefix> option is present in the +arguments to be passed on to git-format-patch(1). + +=back + =head1 SEE ALSO notmuch-import-patch(1), git-format-patch(1), git-send-email(1) -- cgit v1.2.3 From 2f1ccd039ec0b1c4f33d682afc51d6dc6993eb63 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Tue, 5 May 2020 07:49:50 -0700 Subject: mailscripts.el: notmuch-extract-message-patches: improve regexp Signed-off-by: Sean Whitton --- debian/changelog | 2 ++ mailscripts.el | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 53a9be1..e5a1452 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,6 +12,8 @@ mailscripts (0.20-1) UNRELEASED; urgency=medium - Add mailscripts-detach-head-from-existing-branch defcustom. - notmuch-extract-message-patches: set NO-STRICT-MIME argument of `mm-dissect-buffer' to enable extracting patches from more messages. + - notmuch-extract-message-patches: attempt to improve regexp to + extract more wanted patches. * maildir-import-patch: Prepend "[PATCH fooproject imported]" to the subject lines of patches, unless the user supplies a --subject-prefix option to be passed on to git-format-patch(1). diff --git a/mailscripts.el b/mailscripts.el index 193ca5c..2280f5a 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.18 +;; Version: 0.20 ;; Package-Requires: (notmuch projectile) ;; Copyright (C) 2018, 2019 Sean Whitton @@ -130,8 +130,8 @@ git-format-patch(1)." (let* ((disposition (mm-handle-disposition p)) (filename (cdr (assq 'filename disposition)))) (and filename - (string-match - "^\\(v[0-9]+-\\)?[0-9]+-.+\.\\(patch\\|diff\\|txt\\)$" filename) + (string-match "^\\(v?[0-9]+\\)-.+\\.\\(patch\\|diff\\|txt\\)$" + filename) (mm-pipe-part p "git am")))) mm-handle)))) -- cgit v1.2.3 From d6c60f05fc0b2dd2959a46d866ec2b35dc3c0f7f Mon Sep 17 00:00:00 2001 From: Robbie Harwood Date: Mon, 4 May 2020 14:54:11 -0400 Subject: imap-dl: update for imaplib type changes Of particular note here, imaplib.IMAP4_SSL is now an instance of imaplib.IMAP4. Additionally, semantics around imap.login appear to not match our previous assumption: the function can never not return 'OK', but can raise exceptions. Signed-off-by: Robbie Harwood --- imap-dl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/imap-dl b/imap-dl index a644549..fac7487 100755 --- a/imap-dl +++ b/imap-dl @@ -87,13 +87,14 @@ summary_splitter = Splitter('summary', _summary_re) _fetch_re = rb'^(?P[0-9]+) \(UID (?P[0-9]+) (FLAGS \([\\A-Za-z ]*\) )?BODY\[\] \{(?P[0-9]+)\}$' fetch_splitter = Splitter('fetch', _fetch_re) -def auth_builtin(username:str, imap:imaplib.IMAP4_SSL, +def auth_builtin(username:str, imap:imaplib.IMAP4, conf:configparser.ConfigParser, server:str) -> None: logging.info('Logging in as %s', username) resp:Tuple[str, List[Union[bytes,Tuple[bytes,bytes]]]] - resp = imap.login(username, conf.get('retriever', 'password')) - if resp[0] != 'OK': - raise Exception(f'login failed with {resp} as user {username} on {server}') + try: + imap.login(username, conf.get('retriever', 'password')) + except Exception as e: + raise Exception(f'login failed with {e} as user {username} on {server}') if gssapi: # imaplib auth methods need to be in the form of callables, and they all @@ -131,7 +132,7 @@ if gssapi: response = self.gss_vc.wrap(bytes(reply), response.encrypted) return response.message if response.message else b"" # type: ignore -def auth_gssapi(username:str, imap:imaplib.IMAP4_SSL, +def auth_gssapi(username:str, imap:imaplib.IMAP4, conf:configparser.ConfigParser, server:str) -> None: if not gssapi: raise Exception('Kerberos requested, but python3-gssapi not found') @@ -184,7 +185,7 @@ def scan_msgs(configfile:str, verbose:bool) -> None: ctx.set_ciphers(ssl_ciphers) server:str = conf.get('retriever', 'server') - with imaplib.IMAP4_SSL(host=server, #type: ignore + with imaplib.IMAP4_SSL(host=server, port=int(conf.get('retriever', 'port', fallback=993)), ssl_context=ctx) as imap: username:str = conf.get('retriever', 'username') @@ -212,7 +213,7 @@ def scan_msgs(configfile:str, verbose:bool) -> None: raise Exception(f'selection failed: {resp}') if len(resp[1]) != 1: raise Exception(f'expected exactly one EXISTS response from select, got {resp[1]}') - data:Union[bytes,Tuple[bytes,bytes]] = resp[1][0] + data:Optional[bytes] = resp[1][0] if not isinstance(data, bytes): raise Exception(f'expected bytes in response to SELECT, got {data}') n:int = int(data) @@ -222,10 +223,9 @@ def scan_msgs(configfile:str, verbose:bool) -> None: pull_msgs(imap, n, mdst, on_size_mismatch, delete) logging.getLogger().setLevel(oldloglevel) -def pull_msgs(imap:imaplib.IMAP4_SSL, n:int, mdst:mailbox.Maildir, +def pull_msgs(imap:imaplib.IMAP4, n:int, mdst:mailbox.Maildir, on_size_mismatch:OnSizeMismatch, delete:bool) -> None: sizes_mismatched:List[int] = [] - resp:Tuple[str, List[Union[bytes,Tuple[bytes,bytes]]]] resp = imap.fetch('1:%d'%(n), '(UID RFC822.SIZE)') if resp[0] != 'OK': raise Exception(f'initial FETCH 1:{n} not OK ({resp})') -- cgit v1.2.3 From 392b879521bccd908e5b85dcaa21346f46988659 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Tue, 5 May 2020 07:53:34 -0700 Subject: changelog Signed-off-by: Sean Whitton --- debian/changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/debian/changelog b/debian/changelog index e5a1452..324f261 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ mailscripts (0.20-1) UNRELEASED; urgency=medium * imap-dl: Fix failure when python3-gssapi isn't installed (Closes: #955011). Thanks to Robbie Harwood for the patch. + * imap-dl: Update for imaplib type changes (Closes: #959607). + Thanks to Robbie Harwood for the patch. * notmuch-slurp-debbug: Fix reading configuration file (Closes: #958391). Thanks to intrigeri for the patch. * mailscripts.el: -- cgit v1.2.3 From 544d136c398c6cbd18c3b295bc9778f188db4bb4 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Tue, 5 May 2020 09:02:03 -0700 Subject: add libgit-wrapper-perl to Recommends Signed-off-by: Sean Whitton --- debian/changelog | 1 + debian/control | 1 + 2 files changed, 2 insertions(+) diff --git a/debian/changelog b/debian/changelog index 324f261..aa2df03 100644 --- a/debian/changelog +++ b/debian/changelog @@ -21,6 +21,7 @@ mailscripts (0.20-1) UNRELEASED; urgency=medium option to be passed on to git-format-patch(1). This makes patches generated by this script more easily distinguishable from patches really received by e-mail. + - Add libgit-wrapper-perl to Recommends. * Add mailing list & IRC channel info to CONTRIBUTING.rst. -- Sean Whitton Fri, 27 Mar 2020 11:50:27 -0700 diff --git a/debian/control b/debian/control index ffe889d..739d073 100644 --- a/debian/control +++ b/debian/control @@ -49,6 +49,7 @@ Depends: Recommends: devscripts, git, + libgit-wrapper-perl, notmuch, python3-argcomplete, python3-gssapi, -- cgit v1.2.3 From d6952ffaa96f5dfdd1e842e94034e15ded784b11 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Tue, 5 May 2020 09:08:36 -0700 Subject: maildir-import-patch: more helpful error message if no Git::Wrapper Signed-off-by: Sean Whitton --- maildir-import-patch | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/maildir-import-patch b/maildir-import-patch index 0147c49..91b5143 100755 --- a/maildir-import-patch +++ b/maildir-import-patch @@ -24,7 +24,6 @@ use Cwd; use File::Basename; use File::Temp (); use File::Which; -use Git::Wrapper; use List::MoreUtils "firstidx"; use Mail::Box::Manager; @@ -32,6 +31,8 @@ my $us = basename $0; my $maildir_dir = shift or die "$us: usage: $us MAILDIR [git-format-patch(1) args]\n"; which "git" or die "$us: this script requires git to be installed\n"; +eval { require Git::Wrapper } + or die "$us: this script requires Git::Wrapper (libgit-wrapper-perl)\n"; my $git = Git::Wrapper->new(getcwd); my $toplevel; -- cgit v1.2.3 From 263cc6c4175c316655c269718c28413d441bdb3d Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Tue, 5 May 2020 09:16:06 -0700 Subject: maildir-import-patch: close a handle earlier Signed-off-by: Sean Whitton --- maildir-import-patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maildir-import-patch b/maildir-import-patch index 91b5143..605435b 100755 --- a/maildir-import-patch +++ b/maildir-import-patch @@ -69,8 +69,8 @@ unless ($pid) { or die "couldn't reopen child's STDOUT: $!"; exec qw(git format-patch --no-cc --no-to --stdout --thread=shallow), @ARGV; } -wait; $mbox_file->close; +wait; my $mbox = $mgr->open($mbox_file->filename, type => "mbox", access => "r"); $mgr->copyMessage($maildir, $_) for $mbox->messages; -- cgit v1.2.3 From 6849c19a35335a8b03f8e08eac0e2dcd941d38bc Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Tue, 5 May 2020 10:53:14 -0700 Subject: changelog Signed-off-by: Sean Whitton --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index aa2df03..9b41188 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,7 +3,7 @@ mailscripts (0.20-1) UNRELEASED; urgency=medium * imap-dl: Fix failure when python3-gssapi isn't installed (Closes: #955011). Thanks to Robbie Harwood for the patch. * imap-dl: Update for imaplib type changes (Closes: #959607). - Thanks to Robbie Harwood for the patch. + Thanks to Robbie Harwood for the patch and David Bremner for testing. * notmuch-slurp-debbug: Fix reading configuration file (Closes: #958391). Thanks to intrigeri for the patch. * mailscripts.el: -- cgit v1.2.3 From ab4acbc313dc1a20e166045e61c603053c4f00dc Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Tue, 5 May 2020 10:53:42 -0700 Subject: release mailscripts 0.20 (Debian revision -1) Signed-off-by: Sean Whitton --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 9b41188..11aa2dc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -mailscripts (0.20-1) UNRELEASED; urgency=medium +mailscripts (0.20-1) unstable; urgency=medium * imap-dl: Fix failure when python3-gssapi isn't installed (Closes: #955011). Thanks to Robbie Harwood for the patch. @@ -24,7 +24,7 @@ mailscripts (0.20-1) UNRELEASED; urgency=medium - Add libgit-wrapper-perl to Recommends. * Add mailing list & IRC channel info to CONTRIBUTING.rst. - -- Sean Whitton Fri, 27 Mar 2020 11:50:27 -0700 + -- Sean Whitton Tue, 05 May 2020 10:53:38 -0700 mailscripts (0.19-1) unstable; urgency=medium -- cgit v1.2.3