#!/usr/bin/env python3
# File generated by pre-commit: https://pre-commit.com
# with additional edits to support Square git hooks
import os
import sys
from shutil import which

INSTALL_PYTHON = "python"
ARGS = [
    "hook-impl",
    "--config=.pre-commit-config.yaml",
    "--hook-type=pre-commit",
    "--skip-on-missing-config",
]
ARGS.extend(("--hook-dir", os.path.realpath(os.path.dirname(__file__))))
ARGS.append("--")
ARGS.extend(sys.argv[1:])

DNE = "`pre-commit` not found. Make sure to install into your virtualenv before committing"  # NOQA
if os.access(INSTALL_PYTHON, os.X_OK):
    CMD = [INSTALL_PYTHON, "-mpre_commit"]
elif which("pre-commit"):
    CMD = ["pre-commit"]
else:
    raise SystemExit(DNE)

CMD.extend(ARGS)
os.execvp(CMD[0], CMD)
