mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-09 12:54:17 +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:
|
def branch_follows_pattern(patterns: AbstractSet[str]) -> bool:
|
||||||
try:
|
try:
|
||||||
ref_name = cmd_output("git", "symbolic-ref", "HEAD")
|
ref_name = cmd_output('git', 'symbolic-ref', 'HEAD')
|
||||||
except CalledProcessError:
|
except CalledProcessError:
|
||||||
return False
|
return False
|
||||||
chunks = ref_name.strip().split("/")
|
chunks = ref_name.strip().split('/')
|
||||||
branch_name = "/".join(chunks[2:])
|
branch_name = '/'.join(chunks[2:])
|
||||||
return any(re.match(p, branch_name) for p in patterns)
|
return any(re.match(p, branch_name) for p in patterns)
|
||||||
|
|
||||||
|
|
||||||
def main(argv: Sequence[str] | None = None) -> int:
|
def main(argv: Sequence[str] | None = None) -> int:
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-p",
|
'-p',
|
||||||
"--pattern",
|
'--pattern',
|
||||||
action="append",
|
action='append',
|
||||||
help=("regex pattern that the name of the branch must comply with"),
|
help=('regex pattern that the name of the branch must comply with'),
|
||||||
)
|
)
|
||||||
args = parser.parse_args(argv)
|
args = parser.parse_args(argv)
|
||||||
return OK if branch_follows_pattern(frozenset(args.pattern)) else ERROR
|
return OK if branch_follows_pattern(frozenset(args.pattern)) else ERROR
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == '__main__':
|
||||||
raise SystemExit(main())
|
raise SystemExit(main())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue