Commit 78715cc6 authored by Arkadiusz Hiler's avatar Arkadiusz Hiler

parsemail: Keep diff inside comments

When a comment containing a diff is sent to the mailing list is has the
diff extracted out and we save just the comment body above the patch.

Let's fix that by using payload instead of commentbuf. We still strip
signatures and mailing list footers there.

NOTE: we still use commentbuf for splitting an actual patch into the
diff and the patch's comment.
Signed-off-by: Arkadiusz Hiler's avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
parent 5f8714bd
Pipeline #21738 passed with stage
in 1 minute and 43 seconds
......@@ -468,7 +468,7 @@ def find_content(project, mail, force_comment=False):
if not cpatch:
return ret
ret.comment = Comment(patch=cpatch, date=mail_date(mail),
content=clean_content(commentbuf),
content=clean_content(payload),
headers=mail_headers(mail))
# make sure we always have a valid (series,revision) tuple if we have a
......
......@@ -1008,6 +1008,15 @@ class ReplyPatchTest(TestCase):
self.assertEqual(revisions_num, SeriesRevision.objects.count())
def testCommentWithAPatchShouldRetainDiff(self):
self.patch_update['X-Patchwork-Hint'] = 'comment'
parse_mail(self.patch_update)
comment_msgid = self.patch_update['Message-Id']
comment = Comment.objects.get(msgid=comment_msgid)
self.assertTrue('diff --git' in comment.content)
def tearDown(self):
self.p.delete()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment