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