[Patchew-devel] [PATCH] get_diff_stat improvements

Paolo Bonzini posted 1 patch 6 years, 3 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/patchew-ci tags/patchew/20180316100744.19558-1-pbonzini@redhat.com
api/models.py       |  5 +++--
tests/test_model.py | 29 ++++++++++++++++++++++++++++-
2 files changed, 31 insertions(+), 3 deletions(-)
[Patchew-devel] [PATCH] get_diff_stat improvements
Posted by Paolo Bonzini 6 years, 3 months ago
- Recognize mode change lines and 0-line diffstats from mode changes
- File modes must be at least one character long
---
 api/models.py       |  5 +++--
 tests/test_model.py | 29 ++++++++++++++++++++++++++++-
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/api/models.py b/api/models.py
index 277c112..38426cc 100644
--- a/api/models.py
+++ b/api/models.py
@@ -507,11 +507,12 @@ class Message(models.Model):
             return None
         state = ""
         cur = []
-        patterns = [r"\S*\s*\|\s*[0-9]* \+*-*$",
+        patterns = [r"\S*\s*\|\s*[0-9]*( \+*-*)?$",
                     r"\S* => \S*\s*|\s*[0-9]* \+*-*$",
                     r"[0-9]* files changed",
                     r"1 file changed",
-                    r"(create|delete) mode [0-7]*",
+                    r"(create|delete) mode [0-7]+",
+                    r"mode change [0-7]+",
                     r"rename ",
                    ]
         ret = []
diff --git a/tests/test_model.py b/tests/test_model.py
index 250a922..a542136 100755
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -21,7 +21,7 @@ class ImportTest(PatchewTestCase):
         self.cli_login()
         self.add_project("QEMU", "qemu-devel@nongnu.org")
 
-    def test_get_diff_state(self):
+    def test_get_diff_stat(self):
         expected = """
 MAINTAINERS                                        |   7 +
 Makefile                                           |   9 +-
@@ -112,5 +112,32 @@ create mode 100644 util/authz.c
         self.maxDiff = 100000
         self.assertMultiLineEqual(expected.strip(), msg.get_diff_stat())
 
+    def test_mode_change_diff_stat(self):
+        expected = """
+tests/qemu-iotests/096 | 0
+tests/qemu-iotests/129 | 0
+tests/qemu-iotests/132 | 0
+tests/qemu-iotests/136 | 0
+tests/qemu-iotests/139 | 0
+tests/qemu-iotests/148 | 0
+tests/qemu-iotests/152 | 0
+tests/qemu-iotests/163 | 0
+tests/qemu-iotests/205 | 0
+9 files changed, 0 insertions(+), 0 deletions(-)
+mode change 100644 => 100755 tests/qemu-iotests/096
+mode change 100644 => 100755 tests/qemu-iotests/129
+mode change 100644 => 100755 tests/qemu-iotests/132
+mode change 100644 => 100755 tests/qemu-iotests/136
+mode change 100644 => 100755 tests/qemu-iotests/139
+mode change 100644 => 100755 tests/qemu-iotests/148
+mode change 100644 => 100755 tests/qemu-iotests/152
+mode change 100644 => 100755 tests/qemu-iotests/163
+mode change 100644 => 100755 tests/qemu-iotests/205
+"""
+        self.cli_import("0021-mode-only-patch.mbox.gz")
+        msg = Message.objects.first()
+        self.maxDiff = 100000
+        self.assertMultiLineEqual(expected.strip(), msg.get_diff_stat())
+
 if __name__ == '__main__':
     main()
-- 
2.16.2

_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel