[Patchew-devel] [PATCH 3/3] patchew-cli: also match Link headers pointing to lore.kernel.org

Paolo Bonzini posted 3 patches 2 years, 9 months ago
[Patchew-devel] [PATCH 3/3] patchew-cli: also match Link headers pointing to lore.kernel.org
Posted by Paolo Bonzini 2 years, 9 months ago
These are a common alternative to the "Message-Id" header provided by "git am -m",
so use them in "patchew project update".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 patchew-cli                                  |   3 +++
 tests/data/0037-foo-patch-for-git-am.mbox.gz | Bin 0 -> 359 bytes
 tests/test_import.py                         |  20 +++++++++++++++++++
 3 files changed, 23 insertions(+)
 create mode 100644 tests/data/0037-foo-patch-for-git-am.mbox.gz

diff --git a/patchew-cli b/patchew-cli
index d29b539..f269413 100755
--- a/patchew-cli
+++ b/patchew-cli
@@ -495,12 +495,15 @@ class ProjectCommand(SubCommand):
             cwd=clone,
         ).decode()
         msgid_trailer = 'Message-Id:'.casefold()
+        lore_link_trailer = 'Link: https://lore.kernel.org/r/'.casefold()
         msgids = []
         for x in output.splitlines():
             words = x.split()
             header = x.casefold()
             if header.startswith(msgid_trailer):
                 msgids.append(x[11:].strip())
+            elif header.startswith(lore_link_trailer):
+                msgids.append('%s' % x[32:].rstrip())
         logging.debug("message ids: \n%s" % "\n".join(["  " + x for x in msgids]))
         push_to = project["mirror"].get("pushurl")
         if push_to:
diff --git a/tests/data/0037-foo-patch-for-git-am.mbox.gz b/tests/data/0037-foo-patch-for-git-am.mbox.gz
new file mode 100644
index 0000000000000000000000000000000000000000..ace183aef67739ff82c497825c1ab8f3c5cab069
GIT binary patch
literal 359
zcmV-t0hs<DiwFqV&?RC5128Z%H!WswZ!K_PbYo~OW^ZyWXK8dTVQnsLVsCf=eUHsc
z!$1(l@AFs8QAs!1O+&sAi6})xP-#z=9`Z3s)+W2@cB5AO<4sUJco2pM1Mki6&C2LL
z#Z}(pb4#khi#qQ=GDB6HTesBxC2Vwx2kJ*w(JOVC(yCFTt4#wpxuq00BQ4O6@orS;
za}gp>(jb}!9UgNI>#=yD(x$k5`n|Hl?c>$v`gVthQJZmU@SwUAPP{>Ogl|(7JdVSl
zjim~p)*9ems(p&BwZk#>yiOZ(_hb}xa~IEeGn<Eg%ta6dk?Zp$5=^i^|G-){iYlh-
zniZ%2KWB^qPHg-{feuVk&+W=KR}EE*X_x9q#!9WuoO6Im)-^KLNQ=2Q=ZaZDs*2u`
z!lWWUaosp6{D4XnoQFX$L%!YMIL=QZ%aHK}M@L|mfzwGvC?+R@?~0|ngfFV{|C+V|
F004(~s^$Oy

literal 0
HcmV?d00001

diff --git a/tests/test_import.py b/tests/test_import.py
index d6c57e4..436a3d6 100755
--- a/tests/test_import.py
+++ b/tests/test_import.py
@@ -9,6 +9,8 @@
 # http://opensource.org/licenses/MIT.
 
 
+import subprocess
+
 from api.models import Message, Project
 
 from .patchewtest import PatchewTestCase, main
@@ -143,6 +145,24 @@ class UnprivilegedImportTest(ImportTest):
         s = Message.objects.series_heads()[0]
         self.assertEqual(s.is_merged, True)
 
+    def test_project_update_lore(self):
+        p = Project.objects.all()[0]
+
+        repo = self.create_git_repo()
+        p.git = repo
+        p.save()
+
+        self.cli_import("0013-foo-patch.mbox.gz")
+        subprocess.check_output(
+            ["git", "am", self.get_data_path("0037-foo-patch-for-git-am.mbox.gz")],
+            cwd=repo,
+        )
+        s = Message.objects.series_heads()[0]
+        self.assertEqual(s.is_merged, False)
+        self.check_cli(["project", "update"], cwd=repo)
+        s = Message.objects.series_heads()[0]
+        self.assertEqual(s.is_merged, True)
+
 
 if __name__ == "__main__":
     main()
-- 
2.34.1

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