utils/check-package: require exactly 1 TAB and 2 SP on help text 1st line

Test that the first line starts exactly with one TAB and exactly two
spaces before the text.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Ricardo Martincoski <ricardo.martincoski@datacom.com.br>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
Yann E. MORIN
2024-09-07 19:31:23 +02:00
committed by Thomas Petazzoni
parent 064ddfc997
commit f9e6d39e8e

View File

@@ -154,6 +154,7 @@ class CommentsMenusPackagesOrder(_CheckFunction):
class HelpText(_CheckFunction):
HELP_TEXT_FORMAT = re.compile(r"^\t .{,62}$")
HELP_TEXT_FORMAT_1 = re.compile(r"^\t \S.{,61}$")
URL_ONLY = re.compile(r"^(http|https|git)://\S*$")
def before(self):
@@ -170,12 +171,18 @@ class HelpText(_CheckFunction):
return
if text.strip() == "help":
self.help_text = True
self.help_first_line = True
return
if not self.help_text:
return
if self.HELP_TEXT_FORMAT.match(text.rstrip()):
if self.help_first_line:
help_text_match = self.HELP_TEXT_FORMAT_1
self.help_first_line = False
else:
help_text_match = self.HELP_TEXT_FORMAT
if help_text_match.match(text.rstrip()):
return
if self.URL_ONLY.match(text.strip()):
return