diff --git a/pre_commit_hooks/enforce_branch_name.py b/pre_commit_hooks/enforce_branch_name.py index 170e1c2..6d442d9 100644 --- a/pre_commit_hooks/enforce_branch_name.py +++ b/pre_commit_hooks/enforce_branch_name.py @@ -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())