summaryrefslogtreecommitdiff
path: root/notmuch-extract-patch/notmuch-extract-patch
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2019-11-20 22:19:15 -0700
committerSean Whitton <spwhitton@spwhitton.name>2019-11-20 22:19:15 -0700
commit33afb1e3af7ce05c8f2ce4af354c8908a14573f5 (patch)
tree3c0eae4836e7f20c054c193ac3e76da5e0462dfa /notmuch-extract-patch/notmuch-extract-patch
parent914b13d9c578aab098f427aef88b7cbd5eb3f5a2 (diff)
parent693117551a0e21359ac6dbadba443516c56b04df (diff)
downloadmailscripts-33afb1e3af7ce05c8f2ce4af354c8908a14573f5.tar.gz
Merge tag 'debian/0.14-1' into buster-bpo
mailscripts release 0.14-1 for unstable (sid) [dgit] [dgit distro=debian no-split --quilt=linear] # gpg: Signature made Fri 15 Nov 2019 06:20:35 PM MST # gpg: using RSA key 9B917007AE030E36E4FC248B695B7AE4BF066240 # gpg: Good signature from "Sean Whitton <spwhitton@spwhitton.name>" [ultimate] # Primary key fingerprint: 8DC2 487E 51AB DD90 B5C4 753F 0F56 D055 3B6D 411B # Subkey fingerprint: 9B91 7007 AE03 0E36 E4FC 248B 695B 7AE4 BF06 6240
Diffstat (limited to 'notmuch-extract-patch/notmuch-extract-patch')
-rwxr-xr-xnotmuch-extract-patch/notmuch-extract-patch24
1 files changed, 22 insertions, 2 deletions
diff --git a/notmuch-extract-patch/notmuch-extract-patch b/notmuch-extract-patch/notmuch-extract-patch
index cfd4464..4cfda4c 100755
--- a/notmuch-extract-patch/notmuch-extract-patch
+++ b/notmuch-extract-patch/notmuch-extract-patch
@@ -22,6 +22,7 @@ import sys
import tempfile
import subprocess
import re
+import getopt
def get_body(message):
body = None
@@ -48,8 +49,27 @@ def is_git_patch(msg):
# return ("git-send-email" in msg['x-mailer'] and match)
return match
+def has_reroll_count(msg, v):
+ subject_prefix = get_subject_prefix(msg['subject'])
+ if subject_prefix is not None:
+ return "v"+str(v) in subject_prefix \
+ 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)
+ if match:
+ return match.group(1).split()
+
def main():
- query = sys.argv[1:]
+ try:
+ opts, query = getopt.getopt(sys.argv[1:], "v:", ["reroll-count="])
+ except getopt.GetoptError as err:
+ sys.stderr.write(str(err)+"\n")
+ sys.exit(2)
+ reroll_count = 1
+ for o, a in opts:
+ if o in ("-v", "--reroll-count"):
+ reroll_count = int(a)
with tempfile.NamedTemporaryFile() as in_mb_file:
out = subprocess.check_output(['notmuch', 'show', '--format=mbox']+query)
in_mb_file.write(out)
@@ -59,7 +79,7 @@ def main():
with tempfile.NamedTemporaryFile() as out_mb_file:
out_mb = mailbox.mbox(out_mb_file.name)
for m in in_mb:
- if is_git_patch(m):
+ if is_git_patch(m) and has_reroll_count(m, reroll_count):
sys.stderr.write(m['subject']+"\n")
out_mb.add(m)
out_mb.flush()