Skip to contentSkip to conversation

parsemail: Split PATCH prefix if not single

PATCH New Jose Lamego 1 participant 1 message Feb 10, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 parsemail: Split PATCH prefix if not single

PATCH prefix is not appropriately identified as such if it is not sepparated from following word in an email Subject line. This leads to wrong email parsing and revisions not appended to initial series.

This change allows appropriate email parsing by checking if PATCH prefix in Subject line is not sepparated from following word and adding a space
between them.

[YOCTO #10823]

---
 patchwork/bin/parsemail.py | 7 +++++++
 1 file changed, 7 insertions(+)
patchwork/bin/parsemail.py +7 -0
index c9eb05c..6e13beb 100755
@@ -578,11 +578,18 @@ def find_patch_for_comment(project, refs):
 
 
 split_re = re.compile(r'[,\s]+')
+patch_pref = re.re.compile(r'^.*\[(\s*PATCH\w+).*', re.I)
 
 
 def split_prefixes(prefix):
     """ Turn a prefix string into a list of prefix tokens """
 
+    # Check if PATCH prefix is followed by anoter word without a sepparation
+    # space. Add missing space to allow appropriate parsing
+    if patch_pref.match(prefix):
+        index = prefix.find(patch_pref.match(prefix).group(1))
+        prefix = prefix[:index + 5] + ' ' + prefix[index + 5:]
+
     matches = split_re.split(prefix)
     return [s for s in matches if s != '']
 
Signature · 1 line
1.9.1