diff options
Diffstat (limited to '')
-rwxr-xr-x | ci/lint-commit-msg.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/ci/lint-commit-msg.py b/ci/lint-commit-msg.py index 4198ed4..10c7d18 100755 --- a/ci/lint-commit-msg.py +++ b/ci/lint-commit-msg.py @@ -1,12 +1,13 @@ #!/usr/bin/env python3 import os, sys, json, subprocess, re +from typing import Dict, Tuple, Callable, Optional def call(cmd) -> str: sys.stdout.flush() ret = subprocess.run(cmd, check=True, stdout=subprocess.PIPE, text=True) return ret.stdout -lint_rules = {} +lint_rules: Dict[str, Tuple[Callable, str]] = {} def lint_rule(description: str): def f(func): @@ -14,7 +15,7 @@ def lint_rule(description: str): lint_rules[func.__name__] = (func, description) return f -def get_commit_range() -> str: +def get_commit_range() -> Optional[str]: if len(sys.argv) > 1: return sys.argv[1] # https://github.com/actions/runner/issues/342#issuecomment-590670059 @@ -28,6 +29,7 @@ def get_commit_range() -> str: return event["before"] + "..." + event["after"] elif event_name == "pull_request": return event["pull_request"]["base"]["sha"] + ".." + event["pull_request"]["head"]["sha"] + return None def do_lint(commit_range: str) -> bool: commits = call(["git", "log", "--pretty=format:%h %s", commit_range]).splitlines() @@ -56,7 +58,7 @@ def do_lint(commit_range: str) -> bool: ################################################################################ -NO_PREFIX_WHITELIST = r"^Revert \"(.*)\"|^Release [0-9]|^Update VERSION$" +NO_PREFIX_WHITELIST = r"^Revert \"(.*)\"|^Reapply \"(.*)\"|^Release [0-9]|^Update VERSION$" @lint_rule("Subject line must contain a prefix identifying the sub system") def subsystem_prefix(body): @@ -98,7 +100,7 @@ def no_merge(body): @lint_rule("Subject line should be shorter than 72 characters") def line_too_long(body): - revert = re.search(r"^Revert \"(.*)\"", body[0]) + revert = re.search(r"^Revert \"(.*)\"|^Reapply \"(.*)\"", body[0]) return True if revert else len(body[0]) <= 72 @lint_rule("Prefix should not include C file extensions (use `vo_gpu: ...` not `vo_gpu.c: ...`)") |