]> git.ozlabs.org Git - patchwork/commitdiff
[parser] Accept x-diff patches
authorJeremy Kerr <jk@ozlabs.org>
Fri, 10 Oct 2008 07:08:08 +0000 (18:08 +1100)
committerJeremy Kerr <jk@ozlabs.org>
Fri, 10 Oct 2008 07:08:08 +0000 (18:08 +1100)
We should accept x-diff attachments as well as x-patch.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
apps/patchwork/bin/parsemail.py
apps/patchwork/tests/patchparser.py

index 2acceb5836a871835a42eff65f99360e078b6823..d73343a9407fd5a0c36f2af0604f414189f3595c 100755 (executable)
@@ -138,11 +138,12 @@ def find_content(project, mail):
             continue
 
         payload = part.get_payload(decode=True)
+        subtype = part.get_content_subtype()
 
-        if part.get_content_subtype() == 'x-patch':
+        if subtype in ['x-patch', 'x-diff']:
             patchbuf = payload
 
-        if part.get_content_subtype() == 'plain':
+        elif subtype == 'plain':
             if not patchbuf:
                 (patchbuf, c) = parse_patch(payload)
             else:
index be569c7b4c4d1b8b0537683b7f5c1397264b244e..e508dc08a9beffcf376d5f3bb28baa84a76d44ad 100644 (file)
@@ -61,14 +61,18 @@ class InlinePatchTest(PatchTest):
 class AttachmentPatchTest(InlinePatchTest):
     patch_filename = '0001-add-line.patch'
     test_comment = 'Test for attached patch'
+    content_subtype = 'x-patch'
 
     def setUp(self):
         self.orig_patch = read_patch(self.patch_filename)
         email = create_email(self.test_comment, multipart = True)
-        attachment = MIMEText(self.orig_patch, _subtype = 'x-patch')
+        attachment = MIMEText(self.orig_patch, _subtype = self.content_subtype)
         email.attach(attachment)
         (self.patch, self.comment) = find_content(self.project, email)
 
+class AttachmentXDiffPatchTest(AttachmentPatchTest):
+    content_subtype = 'x-diff'
+
 class UTF8InlinePatchTest(InlinePatchTest):
     patch_filename = '0002-utf-8.patch'
     patch_encoding = 'utf-8'