From 378dc94c9507e25a58f33e32e8885bffde52e5da Mon Sep 17 00:00:00 2001 From: sladro Date: Wed, 11 Feb 2026 13:02:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=9B=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .githooks/pre-commit | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 5c7758c..6a11599 100644 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -1,14 +1,18 @@ #!/usr/bin/env sh set -eu -PYTHON_BIN="${PYTHON:-python}" -if ! command -v "$PYTHON_BIN" >/dev/null 2>&1; then - PYTHON_BIN="python3" +if command -v py >/dev/null 2>&1; then + exec py -3 ".githooks/check_staged_java_encoding.py" fi -if ! command -v "$PYTHON_BIN" >/dev/null 2>&1; then - echo "pre-commit: Python is required to run encoding checks." >&2 - exit 1 +if command -v python >/dev/null 2>&1; then + exec python ".githooks/check_staged_java_encoding.py" fi -exec "$PYTHON_BIN" ".githooks/check_staged_java_encoding.py" +if command -v python3 >/dev/null 2>&1; then + exec python3 ".githooks/check_staged_java_encoding.py" +fi + +echo "pre-commit: Python is required to run encoding checks." >&2 +echo "Install Python 3 or ensure 'py'/'python' is available in PATH." >&2 +exit 1