From: Daniel Axtens Date: Thu, 25 Jan 2018 01:25:25 +0000 (+1100) Subject: tags: be a bit more permissive in what we render to a message X-Git-Tag: v2.0.2~11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5cf8767598398960173f09cf213dfbad70be880e;p=thirdparty%2Fpatchwork.git tags: be a bit more permissive in what we render to a message Currently we render a tag from a comment into a message if it is '^(whatever)-by: .*' We found a patch that had a UTF-8 non-breaking space after the colon, and this was breaking the regex. So just remove the requirement for a space entirely. Closes: #124 Signed-off-by: Daniel Axtens --- diff --git a/patchwork/models.py b/patchwork/models.py index d4075cf3..7986b0f3 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -313,7 +313,7 @@ class EmailMixin(models.Model): content = models.TextField(null=True, blank=True) response_re = re.compile( - r'^(Tested|Reviewed|Acked|Signed-off|Nacked|Reported)-by: .*$', + r'^(Tested|Reviewed|Acked|Signed-off|Nacked|Reported)-by:.*$', re.M | re.I) @property diff --git a/patchwork/tests/test_mboxviews.py b/patchwork/tests/test_mboxviews.py index 0dc4abbe..2d6cdc30 100644 --- a/patchwork/tests/test_mboxviews.py +++ b/patchwork/tests/test_mboxviews.py @@ -39,21 +39,33 @@ class MboxPatchResponseTest(TestCase): """Test that the mbox view appends the Acked-by from a patch comment.""" def setUp(self): - project = create_project() + self.project = create_project() self.person = create_person() - self.patch = create_patch( - project=project, + + def test_patch_response(self): + patch = create_patch( + project=self.project, submitter=self.person, content='comment 1 text\nAcked-by: 1\n') - self.comment = create_comment( - submission=self.patch, + create_comment( + submission=patch, submitter=self.person, content='comment 2 text\nAcked-by: 2\n') - - def test_patch_response(self): - response = self.client.get(reverse('patch-mbox', args=[self.patch.id])) + response = self.client.get(reverse('patch-mbox', args=[patch.id])) self.assertContains(response, 'Acked-by: 1\nAcked-by: 2\n') + def test_patch_utf8_nbsp(self): + patch = create_patch( + project=self.project, + submitter=self.person, + content='patch text\n') + create_comment( + submission=patch, + submitter=self.person, + content=u'comment\nAcked-by:\u00A0 foo') + response = self.client.get(reverse('patch-mbox', args=[patch.id])) + self.assertContains(response, u'\u00A0 foo\n') + class MboxPatchSplitResponseTest(TestCase):