]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
parser: Include extended header lines in diff
authorStephen Finucane <stephen@that.guru>
Tue, 4 Jun 2019 11:55:38 +0000 (12:55 +0100)
committerStephen Finucane <stephen@that.guru>
Tue, 4 Jun 2019 14:58:05 +0000 (15:58 +0100)
Commit 753e4572d updated the parser to consider additional header lines
when deciding where a patch message ends and the diff begins. However,
these additional lines were not captured meaning these patches didn't
have a diff associated with them and they therefore weren't patches in
the Patchwork sense of the term. Correct this and add a test.

Signed-off-by: Stephen Finucane <stephen@that.guru>
patchwork/parser.py
patchwork/tests/mail/0022-git-mode-change.mbox [new file with mode: 0644]
patchwork/tests/test_parser.py

index a50e3ae7da411cdeff887b62e0ad4c1b5a7a34b7..7d7b5717d01e52f30600a7964c78669695fe4238 100644 (file)
@@ -851,7 +851,15 @@ def parse_patch(content):
             else:
                 state = 5
         elif state == 6:
-            if line.startswith(('rename to ', 'rename from ',
+            # extended header lines
+            # @see https://git-scm.com/docs/git-diff#_generating_patches_with_p
+            if line.startswith(('old mode ', 'new mode ',
+                                'deleted file mode ',
+                                'new file mode ',
+                                'copy from ', 'copy to ',
+                                'rename from ', 'rename to ',
+                                'similarity index ',
+                                'dissimilarity index ',
                                 'new file mode ', 'index ')):
                 patchbuf += buf + line
                 buf = ''
diff --git a/patchwork/tests/mail/0022-git-mode-change.mbox b/patchwork/tests/mail/0022-git-mode-change.mbox
new file mode 100644 (file)
index 0000000..bf280bb
--- /dev/null
@@ -0,0 +1,23 @@
+From linux-kbuild  Sun Apr 07 23:09:09 2019
+From: Petr Vorel <pvorel@suse.cz>
+Date: Sun, 07 Apr 2019 23:09:09 +0000
+To: linux-kbuild
+Subject: [PATCH 1/1] kconfig: Make nconf-cfg.sh executable
+Message-Id: <20190407230909.20668-1-pvorel@suse.cz>
+X-MARC-Message: https://marc.info/?l=linux-kbuild&m=155467856208923
+
+Although it's not required for the build *conf-cfg.sh scripts to be
+executable (they're run by CONFIG_SHELL), let's be consistent with other
+scripts.
+
+Signed-off-by: Petr Vorel <pvorel@suse.cz>
+---
+ scripts/kconfig/nconf-cfg.sh | 0
+ 1 file changed, 0 insertions(+), 0 deletions(-)
+ mode change 100644 => 100755 scripts/kconfig/nconf-cfg.sh
+
+diff --git a/scripts/kconfig/nconf-cfg.sh b/scripts/kconfig/nconf-cfg.sh
+old mode 100644
+new mode 100755
+-- 
+2.20.1
index f1822029807854d02cc64037c6c439cc6cc81769..c8f8bd9ff9bb2ec68c4e0294ab2dfc19d270d7fe 100644 (file)
@@ -588,6 +588,11 @@ class PatchParseTest(PatchTest):
         self.assertTrue(diff is not None)
         self.assertTrue(message is not None)
 
+    def test_git_mode_change(self):
+        diff, message = self._find_content('0022-git-mode-change.mbox')
+        self.assertTrue(diff is not None)
+        self.assertTrue(message is not None)
+
     def test_cvs_format(self):
         diff, message = self._find_content('0007-cvs-format-diff.mbox')
         self.assertTrue(diff.startswith('Index'))