* [PATCH] patchtest: reject Upstream-Status after scissors
@ 2025-12-15 20:45 lukakrstic031
2025-12-17 7:13 ` [OE-core] " Mathieu Dubois-Briand
0 siblings, 1 reply; 4+ messages in thread
From: lukakrstic031 @ 2025-12-15 20:45 UTC (permalink / raw)
To: openembedded-core; +Cc: l-krstic
From: l-krstic <lukakrstic031@gmail.com>
Upstream-Status must be placed in the patch header before the
scissors line. patchtest currently accepts tags that appear
only after the scissors, which means the tag is lost when the
patch is refreshed by git or devtool.
Update test_upstream_status_presence_format() to distinguish
between tags in the header and tags after the scissors, and
reject the latter.
Fixes: [YOCTO #15940]
Signed-off-by: Luka Krstic <lukakrstic031@gmail.com>
---
meta/lib/patchtest/tests/test_patch.py | 109 +++++++++++++++++++------
1 file changed, 86 insertions(+), 23 deletions(-)
diff --git a/meta/lib/patchtest/tests/test_patch.py b/meta/lib/patchtest/tests/test_patch.py
index d7187a0cb1..08992fbfd1 100644
--- a/meta/lib/patchtest/tests/test_patch.py
+++ b/meta/lib/patchtest/tests/test_patch.py
@@ -50,31 +50,94 @@ class TestPatch(base.Base):
for newpatch in TestPatch.newpatches:
payload = newpatch.__str__()
- if not self.upstream_status_regex.search_string(payload):
- self.fail('Added patch file is missing Upstream-Status: <Valid status> in the commit message',
- data=[('Standard format', self.standard_format), ('Valid status', self.valid_status)])
- for line in payload.splitlines():
+ lines = payload.splitlines()
+
+ scissors_index = None
+ for idx, line in enumerate(lines):
+ if line.lstrip('+') == '---':
+ scissors_index = idx
+ break
+
+ header_has_upstream = False
+ body_has_upstream = False
+
+ for idx, line in enumerate(lines):
+ if not self.upstream_status_regex.search_string(line):
+ continue
+ if scissors_index is not None and idx > scissors_index:
+ body_has_upstream = True
+ else:
+ header_has_upstream = True
+
+ if not header_has_upstream:
+ if body_has_upstream:
+ self.fail(
+ 'Upstream-Status is present only after the patch scissors ("---"). '
+ 'It must be placed in the patch header before the scissors line.',
+ data=[
+ ('Standard format', self.standard_format),
+ ('Valid status', self.valid_status),
+ ],
+ )
+ else:
+ self.fail(
+ 'Added patch file is missing Upstream-Status: <Valid status> in the commit message',
+ data=[
+ ('Standard format', self.standard_format),
+ ('Valid status', self.valid_status),
+ ],
+ )
+
+ for idx, line in enumerate(lines):
if self.patchmetadata_regex.match(line):
continue
- if self.upstream_status_regex.search_string(line):
- if parse_upstream_status.inappropriate_status_mark.searchString(line):
- try:
- parse_upstream_status.upstream_status_inappropriate_info.parseString(line.lstrip('+'))
- except pyparsing.ParseException as pe:
- self.fail('Upstream-Status is Inappropriate, but no reason was provided',
- data=[('Current', pe.pstr), ('Standard format', 'Upstream-Status: Inappropriate [reason]')])
- elif parse_upstream_status.submitted_status_mark.searchString(line):
- try:
- parse_upstream_status.upstream_status_submitted_info.parseString(line.lstrip('+'))
- except pyparsing.ParseException as pe:
- self.fail('Upstream-Status is Submitted, but it is not mentioned where',
- data=[('Current', pe.pstr), ('Standard format', 'Upstream-Status: Submitted [where]')])
- else:
- try:
- parse_upstream_status.upstream_status.parseString(line.lstrip('+'))
- except pyparsing.ParseException as pe:
- self.fail('Upstream-Status is in incorrect format',
- data=[('Current', pe.pstr), ('Standard format', self.standard_format), ('Valid status', self.valid_status)])
+ if not self.upstream_status_regex.search_string(line):
+ continue
+ if scissors_index is not None and idx > scissors_index:
+ self.fail(
+ 'Upstream-Status must be placed in the patch header before the scissors line ("---"), '
+ 'but was found afterwards.',
+ data=[
+ ('Current', line.lstrip('+')),
+ ('Standard format', self.standard_format),
+ ('Valid status', self.valid_status),
+ ],
+ )
+
+ if parse_upstream_status.inappropriate_status_mark.searchString(line):
+ try:
+ parse_upstream_status.upstream_status_inappropriate_info.parseString(line.lstrip('+'))
+ except pyparsing.ParseException as pe:
+ self.fail(
+ 'Upstream-Status is Inappropriate, but no reason was provided',
+ data=[
+ ('Current', pe.pstr),
+ ('Standard format', 'Upstream-Status: Inappropriate [reason]'),
+ ],
+ )
+ elif parse_upstream_status.submitted_status_mark.searchString(line):
+ try:
+ parse_upstream_status.upstream_status_submitted_info.parseString(line.lstrip('+'))
+ except pyparsing.ParseException as pe:
+ self.fail(
+ 'Upstream-Status is Submitted, but it is not mentioned where',
+ data=[
+ ('Current', pe.pstr),
+ ('Standard format', 'Upstream-Status: Submitted [where]'),
+ ],
+ )
+ else:
+ try:
+ parse_upstream_status.upstream_status.parseString(line.lstrip('+'))
+ except pyparsing.ParseException as pe:
+ self.fail(
+ 'Upstream-Status is in incorrect format',
+ data=[
+ ('Current', pe.pstr),
+ ('Standard format', self.standard_format),
+ ('Valid status', self.valid_status),
+ ],
+ )
def test_signed_off_by_presence(self):
if not TestPatch.newpatches:
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [OE-core] [PATCH] patchtest: reject Upstream-Status after scissors
2025-12-15 20:45 [PATCH] patchtest: reject Upstream-Status after scissors lukakrstic031
@ 2025-12-17 7:13 ` Mathieu Dubois-Briand
[not found] ` <CABTLy3aZichqpsbZn3m84i-6b7_FdDgoCSkig3=SYQYWLvA66Q@mail.gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Mathieu Dubois-Briand @ 2025-12-17 7:13 UTC (permalink / raw)
To: lukakrstic031, openembedded-core
On Mon Dec 15, 2025 at 9:45 PM CET, Luka Krstic via lists.openembedded.org wrote:
> From: l-krstic <lukakrstic031@gmail.com>
>
> Upstream-Status must be placed in the patch header before the
> scissors line. patchtest currently accepts tags that appear
> only after the scissors, which means the tag is lost when the
> patch is refreshed by git or devtool.
>
> Update test_upstream_status_presence_format() to distinguish
> between tags in the header and tags after the scissors, and
> reject the latter.
>
> Fixes: [YOCTO #15940]
> Signed-off-by: Luka Krstic <lukakrstic031@gmail.com>
> ---
Hi Luka,
Thanks for your patch.
It is conflicting a lot with existing code on master branch: are you
based on a recent master branch on your side?
Thanks,
Mathieu
--
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [OE-core] [PATCH] patchtest: reject Upstream-Status after scissors
[not found] ` <CABTLy3aZichqpsbZn3m84i-6b7_FdDgoCSkig3=SYQYWLvA66Q@mail.gmail.com>
@ 2025-12-17 12:20 ` Mathieu Dubois-Briand
[not found] ` <20251217204031.3022279-1-lukakrstic031@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Mathieu Dubois-Briand @ 2025-12-17 12:20 UTC (permalink / raw)
To: Лука Крстић
Cc: openembedded-core@lists.openembedded.org, Steve Sakoman,
Yoann Congal
On Wed Dec 17, 2025 at 8:25 AM CET, Лука Крстић wrote:
> Hi Mathieu,
>
> Thanks for the quick feedback.
> I am based on the scarthgap branch.
> I guess that is not good. Can you tell me what should be the base?
>
Hi Luka,
So I believe you wanted to get this patch merged in the scarthgap
branch, which raises two points:
- any change you want to contribute in a stable branch must have been
first accepted in the master branch, except if it does not make sense
to merge it in master.
- patches targeting a stable branch must include the branch name in the
mail prefix.
More details can be found here:
https://docs.yoctoproject.org/dev/contributor-guide/submit-changes.html#submitting-changes-to-stable-release-branches
So given the content of your patch, I believe this should be first
merged in master.
Also, backport in stable branches should be reserved to bug or security
fixes. I'm not involved in this decision, but I'm not fully convinced
this patch meets the requirements.
Thanks,
Mathieu
--
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] patchtest: reject Upstream-Status after scissors
[not found] ` <20251217204031.3022279-1-lukakrstic031@gmail.com>
@ 2025-12-17 20:26 ` Luka Krstic
0 siblings, 0 replies; 4+ messages in thread
From: Luka Krstic @ 2025-12-17 20:26 UTC (permalink / raw)
To: openembedded-core; +Cc: Mathieu Dubois-Briand, Luka Krstic
Upstream-Status must be placed in the patch header before the
scissors line. patchtest currently accepts tags that appear
only after the scissors, which means the tag is lost when the
patch is refreshed by git or devtool.
Update test_upstream_status_presence_format() to distinguish
between tags in the header and tags after the scissors, and
reject the latter.
Fixes: [YOCTO #15940]
Signed-off-by: Luka Krstic <lukakrstic031@gmail.com>
---
meta/lib/patchtest/tests/test_patch.py | 153 ++++++++++++++++---------
1 file changed, 99 insertions(+), 54 deletions(-)
diff --git a/meta/lib/patchtest/tests/test_patch.py b/meta/lib/patchtest/tests/test_patch.py
index d08b8a5019..3b33b5a199 100644
--- a/meta/lib/patchtest/tests/test_patch.py
+++ b/meta/lib/patchtest/tests/test_patch.py
@@ -45,62 +45,107 @@ class TestPatch(base.Base):
for newpatch in TestPatch.newpatches:
payload = newpatch.__str__()
- if not patchtest_patterns.upstream_status_regex.search_string(payload):
- self.fail(
- "Added patch file is missing Upstream-Status: <Valid status> in the commit message",
- data=[
- ("Standard format", self.standard_format),
- ("Valid status", self.valid_status),
- ],
- )
- for line in payload.splitlines():
+ lines = payload.splitlines()
+
+ scissors_index = None
+ for idx, line in enumerate(lines):
+ if line.lstrip("+") == "---":
+ scissors_index = idx
+ break
+
+ header_has_upstream = False
+ body_has_upstream = False
+
+ for idx, line in enumerate(lines):
+ if not patchtest_patterns.upstream_status_regex.search_string(line):
+ continue
+
+ if scissors_index is not None and idx > scissors_index:
+ body_has_upstream = True
+ else:
+ header_has_upstream = True
+
+ if not header_has_upstream:
+ if body_has_upstream:
+ self.fail(
+ 'Upstream-Status is present only after the patch scissors. '
+ "It must be placed in the patch header before the scissors line.",
+ data=[
+ ("Standard format", self.standard_format),
+ ("Valid status", self.valid_status),
+ ],
+ )
+ else:
+ self.fail(
+ "Added patch file is missing Upstream-Status: <Valid status> in the commit message",
+ data=[
+ ("Standard format", self.standard_format),
+ ("Valid status", self.valid_status),
+ ],
+ )
+
+ for idx, line in enumerate(lines):
if patchtest_patterns.patchmetadata_regex.match(line):
continue
- if patchtest_patterns.upstream_status_regex.search_string(line):
- if patchtest_patterns.inappropriate.searchString(line):
- try:
- patchtest_patterns.upstream_status_inappropriate_info.parseString(
- line.lstrip("+")
- )
- except pyparsing.ParseException as pe:
- self.fail(
- "Upstream-Status is Inappropriate, but no reason was provided",
- data=[
- ("Current", pe.pstr),
- (
- "Standard format",
- "Upstream-Status: Inappropriate [reason]",
- ),
- ],
- )
- elif patchtest_patterns.submitted.searchString(line):
- try:
- patchtest_patterns.upstream_status_submitted_info.parseString(
- line.lstrip("+")
- )
- except pyparsing.ParseException as pe:
- self.fail(
- "Upstream-Status is Submitted, but it is not mentioned where",
- data=[
- ("Current", pe.pstr),
- (
- "Standard format",
- "Upstream-Status: Submitted [where]",
- ),
- ],
- )
- else:
- try:
- patchtest_patterns.upstream_status.parseString(line.lstrip("+"))
- except pyparsing.ParseException as pe:
- self.fail(
- "Upstream-Status is in incorrect format",
- data=[
- ("Current", pe.pstr),
- ("Standard format", self.standard_format),
- ("Valid status", self.valid_status),
- ],
- )
+
+ if not patchtest_patterns.upstream_status_regex.search_string(line):
+ continue
+
+ if scissors_index is not None and idx > scissors_index:
+ self.fail(
+ 'Upstream-Status must be placed in the patch header before the scissors line, '
+ "but was found afterwards.",
+ data=[
+ ("Current", line.lstrip("+")),
+ ("Standard format", self.standard_format),
+ ("Valid status", self.valid_status),
+ ],
+ )
+
+ if patchtest_patterns.inappropriate.searchString(line):
+ try:
+ patchtest_patterns.upstream_status_inappropriate_info.parseString(
+ line.lstrip("+")
+ )
+ except pyparsing.ParseException as pe:
+ self.fail(
+ "Upstream-Status is Inappropriate, but no reason was provided",
+ data=[
+ ("Current", pe.pstr),
+ (
+ "Standard format",
+ "Upstream-Status: Inappropriate [reason]",
+ ),
+ ],
+ )
+ elif patchtest_patterns.submitted.searchString(line):
+ try:
+ patchtest_patterns.upstream_status_submitted_info.parseString(
+ line.lstrip("+")
+ )
+ except pyparsing.ParseException as pe:
+ self.fail(
+ "Upstream-Status is Submitted, but it is not mentioned where",
+ data=[
+ ("Current", pe.pstr),
+ (
+ "Standard format",
+ "Upstream-Status: Submitted [where]",
+ ),
+ ],
+ )
+ else:
+ try:
+ patchtest_patterns.upstream_status.parseString(line.lstrip("+"))
+ except pyparsing.ParseException as pe:
+ self.fail(
+ "Upstream-Status is in incorrect format",
+ data=[
+ ("Current", pe.pstr),
+ ("Standard format", self.standard_format),
+ ("Valid status", self.valid_status),
+ ],
+ )
def test_signed_off_by_presence(self):
if not TestPatch.newpatches:
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-12-17 20:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-15 20:45 [PATCH] patchtest: reject Upstream-Status after scissors lukakrstic031
2025-12-17 7:13 ` [OE-core] " Mathieu Dubois-Briand
[not found] ` <CABTLy3aZichqpsbZn3m84i-6b7_FdDgoCSkig3=SYQYWLvA66Q@mail.gmail.com>
2025-12-17 12:20 ` Mathieu Dubois-Briand
[not found] ` <20251217204031.3022279-1-lukakrstic031@gmail.com>
2025-12-17 20:26 ` [PATCH v2] " Luka Krstic
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.