The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(code-health): git hooks work with MSYS path conversion off
Teknium51483660d301
diff --git a/scripts/check b/scripts/checkold mode 100755new mode 100644index 21c4cb53aed..a6444d14ca3--- a/scripts/check+++ b/scripts/check@@ -61,12 +61,16 @@ done[ -n "$py" ] || py="$(command -v python3 || command -v python)" || {echo "scripts/check hook: no python3 or python on PATH" >&2; exit 1; }judge() { # judge TREE-ISH ARGS...: check out TREE-ISH alone and run its own scripts/check ARGS- local tree=$1 tmp rc+ local tree=$1 tmp dir rcshifttmp="$(mktemp -d)" || return 1- GIT_INDEX_FILE="$tmp/index" git read-tree "$tree" &&- GIT_INDEX_FILE="$tmp/index" git checkout-index -a --prefix="$tmp/tree/" &&- GIT_DIR="$git_dir" "$py" "$tmp/tree/scripts/check" "$@" </dev/null+ # Git for Windows: native git and python get this path verbatim when MSYS path conversion+ # is off (MSYS_NO_PATHCONV=1, as Hermes' terminal sets it), so hand them C:/... spelling.+ dir="$tmp"+ if command -v cygpath >/dev/null 2>&1; then dir="$(cygpath -m "$tmp")" || dir="$tmp"; fi+ GIT_INDEX_FILE="$dir/index" git read-tree "$tree" &&+ GIT_INDEX_FILE="$dir/index" git checkout-index -a --prefix="$dir/tree/" &&+ GIT_DIR="$git_dir" "$py" "$dir/tree/scripts/check" "$@" </dev/nullrc=$?rm -rf "$tmp"return $rcdiff --git a/tests/scripts/test_code_health_cli.py b/tests/scripts/test_code_health_cli.pyindex 883bab15b88..f694c673bef 100644--- a/tests/scripts/test_code_health_cli.py+++ b/tests/scripts/test_code_health_cli.py@@ -337,6 +337,37 @@ def test_a_branch_cannot_relax_its_own_switch(tmp_path, monkeypatch, capsys):assert cli.main([]) == 1, capsys.readouterr().out+# --- F23: the hooks under Git for Windows with MSYS path conversion disabled -----------------+++def test_hooks_run_with_msys_path_conversion_disabled(tmp_path):+ """Hermes' Windows terminal exports both variables, so native git and python see the hook's+ paths verbatim: a POSIX `/c/...` temp path then reaches them unconverted. Inert elsewhere."""+ repo, remote = _pushable(tmp_path)+ _branch_with_checker(repo, "feature", {"pkg/d.py": "def d():\n return 4\n"})+ for kind in ("pre-commit", "pre-push"):+ assert _check(repo, "--install-hook", kind).returncode == 0+ env = {**_env(), "MSYS_NO_PATHCONV": "1", "MSYS2_ARG_CONV_EXCL": "*"}++ _write(repo, {"pkg/e.py": _SWALLOW})+ _git(repo, "add", "--", "pkg/e.py")+ commit = _sh(repo, "git", "commit", "-q", "-m", "swallow", env=env)+ assert commit.returncode != 0 and "BLE001" in commit.stdout + commit.stderr, commit.stdout + commit.stderr+ _write(repo, {"pkg/e.py": "def e():\n return 5\n"})+ _git(repo, "add", "--", "pkg/e.py")+ commit = _sh(repo, "git", "commit", "-q", "-m", "clean", env=env)+ assert commit.returncode == 0, commit.stdout + commit.stderr++ push = _sh(repo, "git", "push", "-q", "origin", "feature", env=env)+ assert push.returncode == 0, push.stdout + push.stderr+ assert _remote_ref(remote, "feature") == _git(repo, "rev-parse", "HEAD")+ _write(repo, {"pkg/f.py": _SWALLOW})+ _git(repo, "add", "--", "pkg/f.py")+ _git(repo, "commit", "-q", "--no-verify", "-m", "swallow")+ push = _sh(repo, "git", "push", "-q", "origin", "feature", env=env)+ assert push.returncode != 0 and "BLE001" in push.stdout + push.stderr, push.stdout + push.stderr++# --- m4: the CI guards that ran outside the lint workflow --------------------------------------