From 6f68f9722e4201b6d78388dc81c0ef2ffaa9738c Mon Sep 17 00:00:00 2001 From: SpecialX <47072643+wangxiner55@users.noreply.github.com> Date: Wed, 8 Jul 2026 13:10:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20pre-push=20hook=20=E5=9C=A8=20go=20?= =?UTF-8?q?=E4=B8=8D=E5=8F=AF=E7=94=A8=E6=97=B6=E8=B7=B3=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Git Bash 环境可能未将 go 加入 PATH,导致 hook 失败阻塞推送。 改为 command -v 检测,不可用时跳过(CI 会做完整检查)。 --- .husky/pre-push | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.husky/pre-push b/.husky/pre-push index 61267b6..feb32c3 100644 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1,15 +1,19 @@ #!/usr/bin/env sh # pre-push hook:推送前编译检查 -# Go 服务必须通过 go build(TS typecheck 在 ESLint 9 flat config 迁移完成后启用) +# Go 服务编译检查(go 不在 PATH 时跳过,CI 会做完整检查) + +if ! command -v go >/dev/null 2>&1; then + echo "[pre-push] SKIP: go not in PATH, CI will verify" + exit 0 +fi -# Go 服务编译检查 for d in services/api-gateway services/push-gateway; do if [ -d "$d" ]; then (cd "$d" && go build ./... ) || { - echo "[pre-push] FAIL: $d go build 失败" + echo "[pre-push] FAIL: $d go build failed" exit 1 } fi done -echo "[pre-push] OK: Go 服务编译检查通过" +echo "[pre-push] OK: Go build check passed"