[PATCH 04/10] parsemail: Handle 'xxx (v2)' style messages
Stephen Finucane
stephen.finucane at intel.com
Mon Jun 13 20:41:36 AEST 2016
Some emails are received in the above format. Might as well support
them.
Signed-off-by: Stephen Finucane <stephen.finucane at intel.com>
---
patchwork/bin/parsemail.py | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/patchwork/bin/parsemail.py b/patchwork/bin/parsemail.py
index 1c7ce0f..f52776e 100755
--- a/patchwork/bin/parsemail.py
+++ b/patchwork/bin/parsemail.py
@@ -268,21 +268,26 @@ def parse_series_marker(subject_prefixes):
return (None, None)
-def parse_version(subject_prefixes):
+def parse_version(subject, subject_prefixes):
"""Extract patch version.
Args:
+ subject: Main body of subject line
subject_prefixes: List of subject prefixes to extract version
from
Returns:
version if found, else 1
"""
- regex = re.compile('^v([0-9]+)$')
+ regex = re.compile('^v(\d+)$')
m = _parse_prefixes(subject_prefixes, regex)
if m:
return int(m.group(1))
+ m = re.search(r'\(([vV]\d+)\)', subject)
+ if m:
+ return int(m.group(1))
+
return 1
@@ -542,7 +547,7 @@ def parse_mail(mail, list_id=None):
author = find_author(mail)
name, prefixes = clean_subject(mail.get('Subject'), [project.linkname])
x, n = parse_series_marker(prefixes)
- version = parse_version(prefixes)
+ version = parse_version(name, prefixes)
refs = find_references(mail)
date = find_date(mail)
headers = find_headers(mail)
--
1.7.4.1
More information about the Patchwork
mailing list