diff mbox series

[b4,1/2] trailers: accept recognized link trailers

Message ID 20230525-closes-tags-v1-1-ed41b1773cb6@tessares.net (mailing list archive)
State Accepted
Headers show
Series trailers: accept recognized link trailers + "Closes" | expand

Commit Message

Matthieu Baerts May 25, 2023, 8:10 p.m. UTC
It looks like all all link trailers were ignored.

Now we accept 'link' and 'buglink' that were already in the list of non
person categories.

Note that existing test files have been modified. You will probably need
to run "pytest --cache-clear" to avoid using the previous version.

Fixes: 7d1a05e ("trailers: ignore non-recognized link trailers")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 b4/__init__.py                                           | 6 ++++--
 tests/samples/trailers-thread-with-cover-followup.mbox   | 1 +
 tests/samples/trailers-thread-with-cover-followup.verify | 1 +
 3 files changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/b4/__init__.py b/b4/__init__.py
index 1af6993..e9e7b64 100644
--- a/b4/__init__.py
+++ b/b4/__init__.py
@@ -1656,7 +1656,8 @@  class LoreMessage:
     def find_trailers(body: str, followup: bool = False) -> Tuple[List[LoreTrailer], List[str]]:
         ignores = {'phone', 'email'}
         headers = {'subject', 'date', 'from'}
-        nonperson = {'fixes', 'subject', 'date', 'link', 'buglink', 'obsoleted-by', 'change-id', 'base-commit'}
+        links = {'link', 'buglink'}
+        nonperson = links | {'fixes', 'subject', 'date', 'obsoleted-by', 'change-id', 'base-commit'}
         # Ignore everything below standard email signature marker
         body = body.split('\n-- \n', 1)[0].strip() + '\n'
         # Fix some more common copypasta trailer wrapping
@@ -1695,7 +1696,8 @@  class LoreMessage:
                     if not mperson and lname not in nonperson:
                         logger.debug('Ignoring %s (not a recognized non-person trailer)', line)
                         continue
-                    if re.search(r'https?://', ovalue):
+                    mlink = re.search(r'https?://', ovalue)
+                    if mlink and lname not in links:
                         logger.debug('Ignoring %s (not a recognized link trailer)', line)
                         continue
 
diff --git a/tests/samples/trailers-thread-with-cover-followup.mbox b/tests/samples/trailers-thread-with-cover-followup.mbox
index d9dc64a..bbdeeeb 100644
--- a/tests/samples/trailers-thread-with-cover-followup.mbox
+++ b/tests/samples/trailers-thread-with-cover-followup.mbox
@@ -225,6 +225,7 @@  To: list@example.org
 > Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
 
 Tested-by: Follow Upper <follow.upper@example.org>
+Link: https://example.org
 
 -- 
 Follow Upper
diff --git a/tests/samples/trailers-thread-with-cover-followup.verify b/tests/samples/trailers-thread-with-cover-followup.verify
index 6478e6f..b42e1ed 100644
--- a/tests/samples/trailers-thread-with-cover-followup.verify
+++ b/tests/samples/trailers-thread-with-cover-followup.verify
@@ -4,6 +4,7 @@  Life imitatus artem.
 
 Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
 Tested-by: Follow Upper <follow.upper@example.org>
+Link: https://example.org
 Reviewed-by: Cover Upper <cover.upper@example.org>
 Signed-off-by: Test Override <test-override@example.com>
 ---