@@ -215,7 +215,8 @@ def find_content(project, mail):
comment = None
if pullurl or patchbuf:
- name = clean_subject(mail.get('Subject'), [project.linkname])
+ (name, prefixes) = clean_subject(mail.get('Subject'),
+ [project.linkname])
patch = Patch(name = name, pull_url = pullurl, content = patchbuf,
date = mail_date(mail), headers = mail_headers(mail))
@@ -289,7 +290,6 @@ def clean_subject(subject, drop_prefixes = None):
in the subject. If drop_prefixes is provided, remove those too,
comparing case-insensitively."""
-
subject = clean_header(subject)
if drop_prefixes is None:
@@ -322,7 +322,7 @@ def clean_subject(subject, drop_prefixes = None):
if prefixes:
subject = '[%s] %s' % (','.join(prefixes), subject)
- return subject
+ return (subject, prefixes)
sig_re = re.compile('^(-- |_+)\n.*', re.S | re.M)
def clean_content(str):
@@ -598,26 +598,30 @@ class PrefixTest(TestCase):
class SubjectTest(TestCase):
def testCleanSubject(self):
- self.assertEquals(clean_subject('meep'), 'meep')
- self.assertEquals(clean_subject('Re: meep'), 'meep')
- self.assertEquals(clean_subject('[PATCH] meep'), 'meep')
- self.assertEquals(clean_subject('[PATCH] meep \n meep'), 'meep meep')
- self.assertEquals(clean_subject('[PATCH RFC] meep'), '[RFC] meep')
- self.assertEquals(clean_subject('[PATCH,RFC] meep'), '[RFC] meep')
- self.assertEquals(clean_subject('[PATCH,1/2] meep'), '[1/2] meep')
+ self.assertEquals(clean_subject('meep'), ('meep', []))
+ self.assertEquals(clean_subject('Re: meep'), ('meep', []))
+ self.assertEquals(clean_subject('[PATCH] meep'), ('meep', []))
+ self.assertEquals(clean_subject("[PATCH] meep \n meep"),
+ ('meep meep', []))
+ self.assertEquals(clean_subject('[PATCH RFC] meep'),
+ ('[RFC] meep', ['RFC']))
+ self.assertEquals(clean_subject('[PATCH,RFC] meep'),
+ ('[RFC] meep', ['RFC']))
+ self.assertEquals(clean_subject('[PATCH,1/2] meep'),
+ ('[1/2] meep', ['1/2']))
self.assertEquals(clean_subject('[PATCH RFC 1/2] meep'),
- '[RFC,1/2] meep')
+ ('[RFC,1/2] meep', ['RFC', '1/2']))
self.assertEquals(clean_subject('[PATCH] [RFC] meep'),
- '[RFC] meep')
+ ('[RFC] meep', ['RFC']))
self.assertEquals(clean_subject('[PATCH] [RFC,1/2] meep'),
- '[RFC,1/2] meep')
+ ('[RFC,1/2] meep', ['RFC', '1/2']))
self.assertEquals(clean_subject('[PATCH] [RFC] [1/2] meep'),
- '[RFC,1/2] meep')
+ ('[RFC,1/2] meep', ['RFC', '1/2']))
self.assertEquals(clean_subject('[PATCH] rewrite [a-z] regexes'),
- 'rewrite [a-z] regexes')
+ ('rewrite [a-z] regexes', []))
self.assertEquals(clean_subject('[PATCH] [RFC] rewrite [a-z] regexes'),
- '[RFC] rewrite [a-z] regexes')
+ ('[RFC] rewrite [a-z] regexes', ['RFC']))
self.assertEquals(clean_subject('[foo] [bar] meep', ['foo']),
- '[bar] meep')
+ ('[bar] meep', ['bar']))
self.assertEquals(clean_subject('[FOO] [bar] meep', ['foo']),
- '[bar] meep')
+ ('[bar] meep', ['bar']))
The patch is a preparation step towards understanding series. It will be handy to parse those prefixes, looking for 'x/n' to retrieve the order of a patch in a series. Signed-off-by: Damien Lespiau <damien.lespiau@intel.com> --- patchwork/bin/parsemail.py | 6 +++--- patchwork/tests/test_patchparser.py | 34 +++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 18 deletions(-)