From e8cb6ae83b98ddf4c8d5c3f9ab4595b12fd36af9 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 28 Oct 2026 10:14:10 +0300 Subject: [PATCH] Hooks: run the public tree check through a Python that works Git for Windows puts a Microsoft Store stub on PATH as python3: it prints "Python" and exits 49, so both hooks failed before running the check. The hooks now try python3, python and py and use the first that is Python 3. Co-Authored-By: Hermes Agent (Nous Research) --- .githooks/pre-commit | 11 ++++++++++- .githooks/pre-push | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 2d7f3fac64..abc64ac4e8 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -1,2 +1,11 @@ #!/bin/sh -exec python3 tools/check_public_tree.py +# Git for Windows puts a `python3` on PATH that is only the Microsoft Store +# stub: it prints "Python" and exits non-zero, so the hook fails with no other +# output. Use the first name that actually runs Python 3. +for py in python3 python py; do + if "$py" -c "import sys; sys.exit(sys.version_info < (3,))" >/dev/null 2>&1; then + exec "$py" tools/check_public_tree.py + fi +done +echo "check_public_tree: no working Python 3 found" >&2 +exit 1 diff --git a/.githooks/pre-push b/.githooks/pre-push index d067dd2267..375b535c0f 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -1,2 +1,11 @@ #!/bin/sh -exec python3 tools/check_public_tree.py --pre-push +# Git for Windows puts a `python3` on PATH that is only the Microsoft Store +# stub: it prints "Python" and exits non-zero, so the hook fails with no other +# output. Use the first name that actually runs Python 3. +for py in python3 python py; do + if "$py" -c "import sys; sys.exit(sys.version_info < (3,))" >/dev/null 2>&1; then + exec "$py" tools/check_public_tree.py --pre-push + fi +done +echo "check_public_tree: no working Python 3 found" >&2 +exit 1