fix: pre-push hook 在 go 不可用时跳过
Git Bash 环境可能未将 go 加入 PATH,导致 hook 失败阻塞推送。 改为 command -v 检测,不可用时跳过(CI 会做完整检查)。
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user