diff mbox series

[07/11] patchtest: test_mbox: skip cover letters

Message ID 20260514194207.1958325-8-tgamblin@baylibre.com
State New
Headers show
Series patchtest: improve testing coverage | expand

Commit Message

Trevor Gamblin May 14, 2026, 7:42 p.m. UTC
When testing directories containing multiple patches, it's possible that
cover letters are present. The user should ideally account for this and
remove them as required, but we can also add some capability to test
whether a given file is actually a cover letter and act appropriately.
Start by adding a new regex pattern in patchtest_patterns.py to detect
this case, then adjust the test_mbox suite to make use of it.

AI-Generated: Uses Claude Code

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
---
 meta/lib/patchtest/patchtest_patterns.py | 1 +
 meta/lib/patchtest/tests/test_mbox.py    | 6 ++++++
 2 files changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/meta/lib/patchtest/patchtest_patterns.py b/meta/lib/patchtest/patchtest_patterns.py
index 1a8db92aa5..b3478d2f0f 100644
--- a/meta/lib/patchtest/patchtest_patterns.py
+++ b/meta/lib/patchtest/patchtest_patterns.py
@@ -57,6 +57,7 @@  invalid_submitters = [pyparsing.Regex("^Upgrade Helper.+"),
 mbox_bugzilla = pyparsing.Regex(r'\[\s?YOCTO.*\]')
 mbox_bugzilla_validation = pyparsing.Regex(r'\[(\s?YOCTO\s?#\s?(\d+)\s?,?)+\]')
 mbox_revert_shortlog_regex = pyparsing.Regex(r'Revert\s+".*"')
+mbox_cover_letter_regex = pyparsing.Regex(r'\[\S+\s+0+/\d+\]')
 mbox_shortlog_maxlength = 90
 # based on https://stackoverflow.com/questions/30281026/regex-parsing-github-usernames-javascript
 mbox_github_username = pyparsing.Regex(r'\B(?<!\${)@([a-z0-9](?:-(?=[a-z0-9])|[a-z0-9]){0,38}(?<=[a-z0-9]))')
diff --git a/meta/lib/patchtest/tests/test_mbox.py b/meta/lib/patchtest/tests/test_mbox.py
index a216028250..d465b58ba6 100644
--- a/meta/lib/patchtest/tests/test_mbox.py
+++ b/meta/lib/patchtest/tests/test_mbox.py
@@ -38,6 +38,9 @@  class TestMbox(base.Base):
             # skip those patches that revert older commits, these do not required the tag presence
             if patchtest_patterns.mbox_revert_shortlog_regex.search_string(commit.shortlog):
                 continue
+            # cover letters (00/N) are not commits and do not need Signed-off-by
+            if patchtest_patterns.mbox_cover_letter_regex.search_string(commit.subject):
+                continue
             if not patchtest_patterns.signed_off_by.search_string(commit.payload):
                 self.fail(
                     'Mbox is missing Signed-off-by. Add it manually or with "git commit --amend -s"',
@@ -53,6 +56,9 @@  class TestMbox(base.Base):
                 # no reason to re-check on revert shortlogs
                 if shortlog.startswith('Revert "'):
                     continue
+                # cover letters (00/N) have series titles, not target: summary format
+                if patchtest_patterns.mbox_cover_letter_regex.search_string(commit.subject):
+                    continue
                 try:
                     patchtest_patterns.shortlog.parseString(shortlog)
                 except pyparsing.ParseException as pe: