kumquat-buildroot/utils/checkpackagelib/lib_patch.py
Yann E. MORIN 39643530f5 utils/check-package: don't ignore check-package
Commit 32934b526b (utils/checkpackagelib: check for Upstream trailers)
introduced a new python module to check Upstream tags in patch files. In
doing so, it introduced a flake8 coding style issue. That was not caught
when applying the change, and neither was it caught by our daily checks,
because the .checkpackagefile was regenerated right just in the next
commit, to apply ignore patterns to existing patch files.

It is a bit sad that one of our checks does not itself passes all our
checks...

Fix that trivial issue now.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
(cherry picked from commit 81bb14a935)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2024-04-28 14:11:15 +02:00

83 lines
2.5 KiB
Python

# See utils/checkpackagelib/readme.txt before editing this file.
# The format of the patch files is tested during the build, so below check
# functions don't need to check for things already checked by running
# "make package-dirclean package-patch".
import os
import re
from checkpackagelib.base import _CheckFunction
from checkpackagelib.lib import NewlineAtEof # noqa: F401
from checkpackagelib.tool import NotExecutable # noqa: F401
class ApplyOrder(_CheckFunction):
APPLY_ORDER = re.compile(r"\d{1,4}-[^/]*$")
def before(self):
if not self.APPLY_ORDER.match(os.path.basename(self.filename)):
return ["{}:0: use name <number>-<description>.patch "
"({}#_providing_patches)"
.format(self.filename, self.url_to_manual)]
class NumberedSubject(_CheckFunction):
NUMBERED_PATCH = re.compile(r"Subject:\s*\[PATCH\s*\d+/\d+\]")
def before(self):
self.git_patch = False
self.lineno = 0
self.text = None
def check_line(self, lineno, text):
if text.startswith("diff --git"):
self.git_patch = True
return
if self.NUMBERED_PATCH.search(text):
self.lineno = lineno
self.text = text
def after(self):
if self.git_patch and self.text:
return ["{}:{}: generate your patches with 'git format-patch -N'"
.format(self.filename, self.lineno),
self.text]
class Sob(_CheckFunction):
SOB_ENTRY = re.compile(r"^Signed-off-by: .*$")
def before(self):
self.found = False
def check_line(self, lineno, text):
if self.found:
return
if self.SOB_ENTRY.search(text):
self.found = True
def after(self):
if not self.found:
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)]