mirror of
https://github.com/rookiestar28/ComfyUI-OpenClaw.git
synced 2026-08-14 00:48:07 +00:00
fix(pre-push): isolate Black cache to repo-local path and auto-recover from Windows lock errors
This commit is contained in:
@@ -20,10 +20,15 @@ case "$UNAME_S" in
|
||||
# It frequently leaves locked .exe files (WinError 5) and blocks hook cleanup.
|
||||
export PRE_COMMIT_HOME="${PRE_COMMIT_HOME:-$ROOT_DIR/.tmp/pre-commit-win}"
|
||||
mkdir -p "$PRE_COMMIT_HOME"
|
||||
# Keep Black cache local to avoid AppData lock/permission errors.
|
||||
export BLACK_CACHE_DIR="${BLACK_CACHE_DIR:-$ROOT_DIR/.tmp/black-cache}"
|
||||
mkdir -p "$BLACK_CACHE_DIR"
|
||||
;;
|
||||
*)
|
||||
export PRE_COMMIT_HOME="${PRE_COMMIT_HOME:-$ROOT_DIR/.tmp/pre-commit}"
|
||||
mkdir -p "$PRE_COMMIT_HOME"
|
||||
export BLACK_CACHE_DIR="${BLACK_CACHE_DIR:-$ROOT_DIR/.tmp/black-cache}"
|
||||
mkdir -p "$BLACK_CACHE_DIR"
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -114,6 +119,10 @@ run_pre_commit_safe() {
|
||||
# Avoid removing this block; without it, pre-push can hang/fail repeatedly on Windows.
|
||||
echo "[pre-push] WARN: pre-commit cache appears locked by another process; running cache reset + single retry." >&2
|
||||
reset_cache
|
||||
if [ -n "${BLACK_CACHE_DIR:-}" ] && [ -d "$BLACK_CACHE_DIR" ]; then
|
||||
rm -rf "$BLACK_CACHE_DIR" 2>/dev/null || true
|
||||
mkdir -p "$BLACK_CACHE_DIR"
|
||||
fi
|
||||
pre-commit "$@"
|
||||
rm -f "$tmp_log"
|
||||
rm -f "$lower_log"
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
# Keep Black cache local to avoid AppData lock/permission errors on Windows.
|
||||
export BLACK_CACHE_DIR="${BLACK_CACHE_DIR:-$ROOT_DIR/.tmp/black-cache}"
|
||||
mkdir -p "$BLACK_CACHE_DIR"
|
||||
|
||||
if command -v python >/dev/null 2>&1; then
|
||||
# CRITICAL cross-platform guard:
|
||||
# WSL sometimes has only `python3`, while Windows shells usually expose `python`.
|
||||
|
||||
Reference in New Issue
Block a user