# Path: pre_commit_hooks/util.py
# class CalledProcessError(RuntimeError):
#     pass
# 
# Path: pre_commit_hooks/util.py
# def cmd_output(*cmd: str, retcode: int | None = 0, **kwargs: Any) -> str:
#     kwargs.setdefault('stdout', subprocess.PIPE)
#     kwargs.setdefault('stderr', subprocess.PIPE)
#     proc = subprocess.Popen(cmd, **kwargs)
#     stdout, stderr = proc.communicate()
#     stdout = stdout.decode()
#     if retcode is not None and proc.returncode != retcode:
#         raise CalledProcessError(cmd, retcode, proc.returncode, stdout, stderr)
#     return stdout


import argparse
import re
from typing import AbstractSet
from typing import Sequence
from pre_commit_hooks.util import CalledProcessError
from pre_commit_hooks.util import cmd_output
from __future__ import annotations




def is_on_branch(
        protected: AbstractSet[str],
        patterns: AbstractSet[str] = frozenset(),
) -> bool:
    try:

# Path: pre_commit_hooks/util.py
# class CalledProcessError(RuntimeError):
#     pass
# 
# Path: pre_commit_hooks/util.py
# def cmd_output(*cmd: str, retcode: int | None = 0, **kwargs: Any) -> str:
#     kwargs.setdefault('stdout', subprocess.PIPE)
#     kwargs.setdefault('stderr', subprocess.PIPE)
#     proc = subprocess.Popen(cmd, **kwargs)
#     stdout, stderr = proc.communicate()
#     stdout = stdout.decode()
#     if retcode is not None and proc.returncode != retcode:
#         raise CalledProcessError(cmd, retcode, proc.returncode, stdout, stderr)
#     return stdout


# Path: pre_commit_hooks/no_commit_to_branch.py
import argparse
import re
from typing import AbstractSet
from typing import Sequence
from pre_commit_hooks.util import CalledProcessError
from pre_commit_hooks.util import cmd_output

from __future__ import annotations




def is_on_branch(
        protected: AbstractSet[str],
        patterns: AbstractSet[str] = frozenset(),
) -> bool:
    try:

        ref_name = cmd_output('git', 'symbolic-ref', 'HEAD')