All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vincent Fazio <vfazio@gmail.com>
To: buildroot@buildroot.org
Cc: Ricardo Martincoski <ricardo.martincoski@datacom.com.br>,
	Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>,
	Vincent Fazio <vfazio@gmail.com>
Subject: [Buildroot] [PATCH v2 2/3] utils/checkpackagelib: check for Upstream trailers
Date: Mon,  3 Apr 2023 09:41:04 -0500	[thread overview]
Message-ID: <20230403144105.419341-2-vfazio@gmail.com> (raw)
In-Reply-To: <20230403144105.419341-1-vfazio@gmail.com>

Implement a check-package check for an Upstream: trailer in patches
being applied to packages per a mailing list discussion [0].

No strict formatting checks are implemented for the contents within the
trailer as the needed level of detail will vary patch-to-patch.

Tested with: `./utils/docker-run python3 -m pytest utils/checkpackagelib`

[0] https://lists.buildroot.org/pipermail/buildroot/2023-March/666016.html

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
---
Changes v1 -> v2:
  - Minor updates commit message body
  - Fix unit tests
---
 utils/checkpackagelib/lib_patch.py      | 18 ++++++++++++++++++
 utils/checkpackagelib/test_lib_patch.py | 22 ++++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/utils/checkpackagelib/lib_patch.py b/utils/checkpackagelib/lib_patch.py
index caee36158f..1909d3acd0 100644
--- a/utils/checkpackagelib/lib_patch.py
+++ b/utils/checkpackagelib/lib_patch.py
@@ -61,3 +61,21 @@ class Sob(_CheckFunction):
             return ["{}:0: missing Signed-off-by in the header "
                     "({}#_format_and_licensing_of_the_package_patches)"
                     .format(self.filename, self.url_to_manual)]
+
+class Upstream(_CheckFunction):
+    UPSTREAM_ENTRY = re.compile(r"^Upstream: .*$")
+
+    def before(self):
+        self.found = False
+
+    def check_line(self, lineno, text):
+        if self.found:
+            return
+        if self.UPSTREAM_ENTRY.search(text):
+            self.found = True
+
+    def after(self):
+        if not self.found:
+            return ["{}:0: missing Upstream in the header "
+                    "({}#_additional_patch_documentation)"
+                    .format(self.filename, self.url_to_manual)]
diff --git a/utils/checkpackagelib/test_lib_patch.py b/utils/checkpackagelib/test_lib_patch.py
index 3b6fadf38c..f7487ef329 100644
--- a/utils/checkpackagelib/test_lib_patch.py
+++ b/utils/checkpackagelib/test_lib_patch.py
@@ -94,3 +94,25 @@ Sob = [
 def test_Sob(testname, filename, string, expected):
     warnings = util.check_file(m.Sob, filename, string)
     assert warnings == expected
+
+
+Upstream = [
+    ('good',
+     'patch',
+     'Upstream: https://some/amazing/patch/submission\n',
+     []),
+    ('empty',
+     'patch',
+     '',
+     [['patch:0: missing Upstream in the header (url#_additional_patch_documentation)']]),
+    ('bad',
+     'patch',
+     'Subject: [PATCH 24/105] text\n',
+     [['patch:0: missing Upstream in the header (url#_additional_patch_documentation)']]),
+    ]
+
+
+@pytest.mark.parametrize('testname,filename,string,expected', Upstream)
+def test_Upstream(testname, filename, string, expected):
+    warnings = util.check_file(m.Upstream, filename, string)
+    assert warnings == expected
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  reply	other threads:[~2023-04-03 14:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-03 14:41 [Buildroot] [PATCH v2 1/3] docs/manual: rewrite section for upstream documentation Vincent Fazio
2023-04-03 14:41 ` Vincent Fazio [this message]
2023-04-03 14:41 ` [Buildroot] [PATCH v2 3/3] .checkpackageignore: add entries missing Upstream trailer Vincent Fazio
2023-04-15 17:54 ` [Buildroot] [PATCH v2 1/3] docs/manual: rewrite section for upstream documentation Yann E. MORIN
2023-04-23  9:43 ` Peter Korsgaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230403144105.419341-2-vfazio@gmail.com \
    --to=vfazio@gmail.com \
    --cc=buildroot@buildroot.org \
    --cc=ricardo.martincoski@datacom.com.br \
    --cc=thomas.de_schampheleire@nokia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.