[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2024-05-31 11:10:05 +00:00
parent 86d5ab84cb
commit 3be58c150c

View file

@ -14,25 +14,25 @@ ERROR = 1
def branch_follows_pattern(patterns: AbstractSet[str]) -> bool:
try:
ref_name = cmd_output("git", "symbolic-ref", "HEAD")
ref_name = cmd_output('git', 'symbolic-ref', 'HEAD')
except CalledProcessError:
return False
chunks = ref_name.strip().split("/")
branch_name = "/".join(chunks[2:])
chunks = ref_name.strip().split('/')
branch_name = '/'.join(chunks[2:])
return any(re.match(p, branch_name) for p in patterns)
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument(
"-p",
"--pattern",
action="append",
help=("regex pattern that the name of the branch must comply with"),
'-p',
'--pattern',
action='append',
help=('regex pattern that the name of the branch must comply with'),
)
args = parser.parse_args(argv)
return OK if branch_follows_pattern(frozenset(args.pattern)) else ERROR
if __name__ == "__main__":
if __name__ == '__main__':
raise SystemExit(main())