Commit 5f8714bd authored by Arkadiusz Hiler's avatar Arkadiusz Hiler

parsemail: Handle duplicate comments more gracefully

Currently each time there is a comment with a duplicate msg-id, ADMINS
get an email with an exception.

Let's be more graceful and just debug log it.
Signed-off-by: Arkadiusz Hiler's avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
parent efad0307
Pipeline #21726 passed with stage
in 1 minute and 11 seconds
......@@ -844,8 +844,11 @@ def parse_mail(mail):
comment.patch = patch
comment.submitter = author
comment.msgid = msgid
comment.save()
LOGGER.debug('Comment saved')
try:
comment.save()
LOGGER.debug('Comment saved')
except IntegrityError:
LOGGER.debug('Duplicate comment, ignoring')
series_revision_complete.disconnect(on_revision_complete)
......
......@@ -337,12 +337,12 @@ class MultipleProjectPatchTest(TestCase):
self.p2.delete()
class DuplicatePatchInRevision(TransactionTestCase):
class DuplicateMails(TransactionTestCase):
fixtures = ['default_states', 'default_events']
test_comment = 'Test Comment'
patch_filename = '0001-add-line.patch'
def testParsedProjects(self):
def testPatchWithSameOrdinal(self):
patch = read_patch(self.patch_filename)
patch1 = create_email(self.test_comment + '\n' + patch,
subject="[PATCH 1/2] Meep Meep]")
......@@ -358,6 +358,20 @@ class DuplicatePatchInRevision(TransactionTestCase):
patch2['Message-Id'] = '<1@example.com>'
parse_mail(patch2)
def testCommentSameMsgId(self):
patch = read_patch(self.patch_filename)
patch = create_email(self.test_comment + '\n' + patch,
subject="[PATCH] Meep Meep]")
parse_mail(patch)
comment = create_email(self.test_comment,
subject="Re: Meep Meep]",
in_reply_to=patch['Message-Id'])
parse_mail(comment)
parse_mail(comment)
class FDOHaxFromHeaderMangling(TestCase):
fixtures = ['default_states', 'default_events']
......
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