Constant PRECOMMIT_TEMPLATE

Source
pub const PRECOMMIT_TEMPLATE: &str = "#!/usr/bin/env python3\n\n\"\"\"Helper script to be used as a pre-commit hook.\"\"\"\nimport os\nimport sys\nimport subprocess\n\ndef get_project_root():\n    return subprocess.getoutput(\"git rev-parse --show-toplevel\")\n\n{%- if features.gitleaks %}\ndef gitleaks_enabled():\n    \"\"\"Determine if the pre-commit hook for gitleaks is enabled.\"\"\"\n    out = subprocess.getoutput(\"git config --bool hooks.gitleaks\")\n    if out == \"false\":\n        return False\n    return True\n\ndef handle_gitleaks():\n    exitCode = os.WEXITSTATUS(os.system(\"gitleaks protect -v --staged\"))\n    if exitCode == 1:\n        print(\n            \"\"\"Warning: gitleaks has detected sensitive information in your changes.\nTo disable the gitleaks precommit hook run the following command:\n\n    git config hooks.gitleaks false\n\"\"\"\n        )\n        sys.exit(1)\n\n{%- endif %}\n\n{%- if features.taplo %}\ndef handle_taplo():\n    if not os.environ.get(\"COMMIT_SKIP_TAPLO\"):\n        exitcode = os.WEXITSTATUS(os.system(\"taplo format --check\"))\n        if exitcode != 0:\n            print(\"found taplo errors. (set COMMIT_SKIP_TAPLO=1 to skip this check)\")\n            sys.exit(1)\n{%- endif %}\n\n\n{%- if features.cargo %}\ndef handle_cargo():\n    if not os.environ.get(\"COMMIT_SKIP_FMT\"):\n        exitcode = os.WEXITSTATUS(os.system(\"cargo fmt --check\"))\n\n        if exitcode != 0:\n            print(\"found rustfmt errors. (set COMMIT_SKIP_FMT=1 to skip this check)\")\n            sys.exit(1)\n\n    if not os.environ.get(\"COMMIT_SKIP_CLIPPY\"):\n        exitcode = os.WEXITSTATUS(os.system(\"cargo clippy -- -D warnings\"))\n\n        if exitcode != 0:\n            print(\n                \"found clippy warnings. (set COMMIT_SKIP_CLIPPY=1 to skip this check)\"\n            )\n            sys.exit(1)\n{%- endif %}\n\n\n{%- if features.cargo %}\nhandle_cargo()\n{% endif %}\n\n{%- if features.taplo %}\nhandle_taplo()\n{% endif %}\n\n\n{%- if features.gitleaks %}\nif gitleaks_enabled():\n    handle_gitleaks()\nelse:\n    print(\n        \"gitleaks precommit disabled\\\n     (enable with `git config hooks.gitleaks true`)\"\n    )\n{%- endif %}\n\n{#\n   vim: ft=python.jinja2\n#}\n";