mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-03-29 10:16:52 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
86d5ab84cb
commit
3be58c150c
1 changed files with 8 additions and 8 deletions
|
|
@ -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())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue