mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-21 00:57:50 -06:00
fix: give commit_rules.py a --help
This commit is contained in:
1 parent
fd62b21abd
commit
7cbfa53851
1 file changed
+6
-4
@@ -10,6 +10,7 @@ Usage as a hook: python scripts/commit_rules.py MESSAGE_FILE
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import argparse
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -51,10 +52,11 @@ def problems(message: str) -> list[str]:
|
|||||||
|
|
||||||
|
|
||||||
def main(argv: list[str]) -> int:
|
def main(argv: list[str]) -> int:
|
||||||
if len(argv) != 2:
|
parser = argparse.ArgumentParser(
|
||||||
print("usage: commit_rules.py MESSAGE_FILE", file=sys.stderr)
|
allow_abbrev=False, description="Check a commit message against the rules above")
|
||||||
return 2
|
parser.add_argument("message_file", type=Path, help="the message file a commit-msg hook receives")
|
||||||
found = problems(Path(argv[1]).read_text(encoding="utf-8", errors="replace"))
|
args = parser.parse_args(argv[1:])
|
||||||
|
found = problems(args.message_file.read_text(encoding="utf-8", errors="replace"))
|
||||||
for problem in found:
|
for problem in found:
|
||||||
print(f"commit-msg: {problem}", file=sys.stderr)
|
print(f"commit-msg: {problem}", file=sys.stderr)
|
||||||
return 1 if found else 0
|
return 1 if found else 0
|
||||||
|
|||||||
Reference in new issue
Block a user