[meta-oe,RFC] insane: Inappropriate patch reasoning

Message ID AM9PR09MB4642752B0C687EE091EEC380A8759@AM9PR09MB4642.eurprd09.prod.outlook.com
State New
Headers show
Series [meta-oe,RFC] insane: Inappropriate patch reasoning | expand

Commit Message

Konrad Weihmann Dec. 14, 2021, 5:53 p.m. UTC
if a patch uses Upstream-Status: Inappropriate it should provide a machine
readable reasoning in square brackets.

According to latest wiki entry that would be

not author
native
licensing
configuration
enable feature
disable feature
bugfix .*
embedded specific
no upstream
other

a detailed reasoning could be provided as part of the commit message,
but format of the metadata line is fixed.

This patch adds a check to insane.bbclass and warns if there is a
non-compliant reasoning given, or none at all.

In a follow-up this should be turned into an error, as it was done
with missing Upstream-Status

Signed-off-by: Konrad Weihmann <kweihmann@outlook.com>
---
 meta/classes/insane.bbclass | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Patch

diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index 240f3aad62..da26f4662c 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -1191,6 +1191,26 @@  python do_qa_patch() {
                bb.error("Malformed Upstream-Status in patch\n%s\nPlease correct according to %s :\n%s" % (fullpath, guidelines, match_kinda.group(0)))
            else:
                bb.error("Missing Upstream-Status in patch\n%s\nPlease add according to %s ." % (fullpath, guidelines))
+       
+       inappr_message_re = r'Inappropriate(\s+\[(?P<reason>.*)\])*'
+       inappr_reasons = [
+            'not author',
+            'native',
+            'licensing',
+            'configuration',
+            'enable feature',
+            'disable feature',
+            'bugfix .*',
+            'embedded specific',
+            'no upstream',
+            'other',
+       ]
+       for match_inappr in re.finditer(inappr_message_re, content, re.IGNORECASE | re.MULTILINE):
+
+           if 'reason' not in match_inappr.groupdict():
+               bb.warning("Missing Upstream-Status: Inappropriate reasoning in patch\n%s\nPlease add according to %s ." % (fullpath, guidelines))
+           elif not any(re.match(x, match_inappr.groupdict().get('reason', '') or '') for x in inappr_reasons):
+               bb.warning("Malformed Upstream-Status: Inappropriate in patch\n%s\nPlease correct according to %s :\n%s" % (fullpath, guidelines, match_inappr.group(0)))
 }
 
 python do_qa_configure() {