ci/lint-commit-msg: make some minor adjustments to the rules

This commit is contained in:
sfan5 2024-09-23 19:49:01 +02:00
parent 0e6d050c3b
commit b64c53f730
1 changed files with 5 additions and 5 deletions

View File

@ -9,6 +9,7 @@ def call(cmd) -> str:
lint_rules: Dict[str, Tuple[Callable, str]] = {}
# A lint rule should return True if everything is okay
def lint_rule(description: str):
def f(func):
assert func.__name__ not in lint_rules.keys()
@ -37,7 +38,6 @@ def do_lint(commit_range: str) -> bool:
any_failed = False
for commit in commits:
sha, _, _ = commit.partition(' ')
#print(commit)
body = call(["git", "show", "-s", "--format=%B", sha]).splitlines()
failed = []
if len(body) == 0:
@ -58,7 +58,7 @@ def do_lint(commit_range: str) -> bool:
################################################################################
NO_PREFIX_WHITELIST = r"^Revert \"(.*)\"|^Reapply \"(.*)\"|^Release [0-9]|^Update VERSION$"
NO_PREFIX_WHITELIST = r"^Revert \"(.*)\"|^Reapply \"(.*)\"|^Release [0-9]|^Update MPV_VERSION$"
@lint_rule("Subject line must contain a prefix identifying the sub system")
def subsystem_prefix(body):
@ -91,11 +91,11 @@ def no_merge(body):
@lint_rule("Subject line should be shorter than 72 characters")
def line_too_long(body):
revert = re.search(r"^Revert \"(.*)\"|^Reapply \"(.*)\"", body[0])
return True if revert else len(body[0]) <= 72
return revert or len(body[0]) <= 72
@lint_rule("Prefix should not include C file extensions (use `vo_gpu: ...` not `vo_gpu.c: ...`)")
@lint_rule("Prefix should not include file extension (use `vo_gpu: ...` not `vo_gpu.c: ...`)")
def no_file_exts(body):
return not re.search(r"[a-z0-9]\.[ch]: ", body[0])
return not re.search(r"[a-z0-9]\.([chm]|cpp|swift|py): ", body[0])
################################################################################