[PATCH] Make sure the diffs of pull requests are stored in the Patch object.

Guilherme Salgado guilherme.salgado at linaro.org
Tue Feb 15 22:58:47 EST 2011


Signed-off-by: Guilherme Salgado <guilherme.salgado at linaro.org>
---

This patch makes sure we don't throw away the diff of pull requests. Since I
didn't have the mbox file of a pull request handy I copied the existing one
and tweaked it so that I could use it for my test. Hope that's ok.

 apps/patchwork/bin/parsemail.py     |   10 ++--------
 apps/patchwork/tests/patchparser.py |   15 +++++++++++++++
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/apps/patchwork/bin/parsemail.py b/apps/patchwork/bin/parsemail.py
index 700cb6f..f823075 100755
--- a/apps/patchwork/bin/parsemail.py
+++ b/apps/patchwork/bin/parsemail.py
@@ -183,15 +183,9 @@ def find_content(project, mail):
     patch = None
     comment = None
 
-    if patchbuf:
-        mail_headers(mail)
+    if pullurl or patchbuf:
         name = clean_subject(mail.get('Subject'), [project.linkname])
-        patch = Patch(name = name, content = patchbuf,
-                    date = mail_date(mail), headers = mail_headers(mail))
-
-    if pullurl:
-        name = clean_subject(mail.get('Subject'), [project.linkname])
-        patch = Patch(name = name, pull_url = pullurl,
+        patch = Patch(name = name, pull_url = pullurl, content = patchbuf,
                     date = mail_date(mail), headers = mail_headers(mail))
 
     if commentbuf:
diff --git a/apps/patchwork/tests/patchparser.py b/apps/patchwork/tests/patchparser.py
index ff0025a..46cabc3 100644
--- a/apps/patchwork/tests/patchparser.py
+++ b/apps/patchwork/tests/patchparser.py
@@ -333,3 +333,18 @@ class GitPullTest(PatchTest):
         self.assertTrue(patch.pull_url is not None)
         self.assertTrue(patch.content is None)
         self.assertTrue(comment is not None)
+
+    def testGitPullRequestWithDiff(self):
+        mail = read_mail('0002-git-pull-request-with-diff.mbox',
+                        project = self.project)
+        (patch, comment) = find_content(self.project, mail)
+        self.assertTrue(patch is not None)
+        self.assertEqual(
+            ('git://git.kernel.org/pub/scm/linux/kernel/git/tip/'
+             'linux-2.6-tip.git x86-fixes-for-linus'),
+            patch.pull_url)
+        self.assertTrue(
+            patch.content.startswith(
+                'diff --git a/arch/x86/include/asm/smp.h'),
+            patch.content)
+        self.assertTrue(comment is not None)
-- 
1.7.1



More information about the Patchwork mailing list