[PATCH 4/4] parser: remove subject_prefix from imported patch

Philippe Pepiot phil at philpep.org
Sun May 28 04:17:56 AEST 2017


When a patch is imported on a project that have a `subject_prefix`,
remove it from the prefixes since it's a redundant information with the
project.
---
 patchwork/parser.py            | 3 ++-
 patchwork/tests/test_parser.py | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/patchwork/parser.py b/patchwork/parser.py
index e5af55b..5bd82b5 100644
--- a/patchwork/parser.py
+++ b/patchwork/parser.py
@@ -813,7 +813,8 @@ def parse_mail(mail, list_id=None):
 
     msgid = mail.get('Message-Id').strip()
     author = find_author(mail)
-    name, prefixes = clean_subject(subject, [project.linkname])
+    name, prefixes = clean_subject(subject,
+                                   [project.linkname, project.subject_prefix])
     is_comment = subject_check(subject)
     x, n = parse_series_marker(prefixes)
     version = parse_version(name, prefixes)
diff --git a/patchwork/tests/test_parser.py b/patchwork/tests/test_parser.py
index 0430f52..4d089ba 100644
--- a/patchwork/tests/test_parser.py
+++ b/patchwork/tests/test_parser.py
@@ -496,18 +496,23 @@ class MultipleProjectSameListTest(TestCase):
     def test_prefix_matching(self):
         patch = self._parse_mail('[PATCH foo foobar] foo bar')
         self.assertEqual(patch.project, self.p2)
+        self.assertEqual(patch.name, '[foobar] foo bar')
         patch = self._parse_mail('[PATCH foobar bar] foo bar')
         self.assertEqual(patch.project, self.p3)
+        self.assertEqual(patch.name, '[foobar] foo bar')
 
     def test_prefix_not_matching(self):
         patch = self._parse_mail('[PATCH foobar] foo bar')
         self.assertEqual(patch.project, self.p1)
+        self.assertEqual(patch.name, '[foobar] foo bar')
 
     def test_multiple_matching(self):
         patch = self._parse_mail('[PATCH foo foobar bar] meep')
         self.assertEqual(patch.project, self.p2)
+        self.assertEqual(patch.name, '[foobar,bar] meep')
         patch = self._parse_mail('[PATCH bar foobar foo] meep')
         self.assertEqual(patch.project, self.p3)
+        self.assertEqual(patch.name, '[foobar,foo] meep')
 
 
 class ListIdHeaderTest(TestCase):
-- 
2.1.4



More information about the Patchwork mailing list