@@ -213,7 +213,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))
@@ -287,7 +288,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:
@@ -320,7 +320,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):
@@ -594,26 +594,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']))