Files
Genarrative/scripts/check-repository-ci.sh
T
kdletters 5aa616134c
Project CI / AI game creator shell Rust shard 1/4 (push) Successful in 5m30s
Project CI / AI game creator shell Rust shard 3/4 (push) Successful in 5m47s
Project CI / AI game creator shell Rust shard 4/4 (push) Successful in 5m53s
Project CI / AI game creator shell Rust shard 2/4 (push) Successful in 6m8s
Project CI / AI game creator shell Rust smoke (push) Successful in 1m48s
Project CI / AI game creator shell Rust crates (push) Successful in 2m46s
Project CI / Frontend tests (push) Failing after 4m6s
Project CI / Repository checks (push) Successful in 3m57s
Project CI / Native shell tests (push) Successful in 7m40s
Project CI / Backend tests (push) Successful in 8m27s
Project CI / AI game creator shell web tests (push) Successful in 12m53s
修复 Hook 链继承仓库定位变量导致真实仓库被夹具污染
- .husky/pre-commit 与 .husky/pre-push 入口清除 GIT_DIR/GIT_WORK_TREE/GIT_INDEX_FILE 等仓库定位变量

- scripts/check-repository-ci.sh 增加同样的清理,保证本地门禁与 CI 走同一套隔离

- scripts/git-hooks.test.mjs 夹具 Git 调用前自检仓库归属并禁用 Hook,命令落到外部仓库时直接失败

- 守卫用例的子进程必须真的继承 GIT_DIR,避免隔离断言空转

- 更新开发运维文档与 shared-memory/pitfalls.md,记录链接工作树注入形态与配置修复步骤
2026-09-16 10:35:07 +08:00

30 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# 链接工作树推送时 Git 会向 Hook 注入 GIT_DIR 等仓库定位变量;npm 链上的测试夹具会继承
# 它们并绕过 cwd 写到真实仓库,这里统一清除,保证门禁只作用于当前工作树。
unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_COMMON_DIR GIT_PREFIX GIT_CONFIG_PARAMETERS GIT_CEILING_DIRECTORIES
base_ref="${SPACETIME_SCHEMA_BASE_REF:-${1:-}}"
head_ref="${REPOSITORY_CI_HEAD_REF:-${2:-HEAD}}"
if [[ -z "${base_ref}" ]]; then
echo '[repository-ci] 缺少比较基线;请设置 SPACETIME_SCHEMA_BASE_REF 或传入第一个参数。' >&2
exit 1
fi
git cat-file -e "${base_ref}^{commit}" 2>/dev/null || {
echo "[repository-ci] 比较基线不可用: ${base_ref}" >&2
exit 1
}
git cat-file -e "${head_ref}^{commit}" 2>/dev/null || {
echo "[repository-ci] 待检查提交不可用: ${head_ref}" >&2
exit 1
}
echo "[repository-ci] base=${base_ref} head=$(git rev-parse "${head_ref}")"
SPACETIME_SCHEMA_BASE_REF="${base_ref}" npm run lint
npm run test -- apps/ai-game-creator-shell/tests/appSurface.test.ts
npm run build
git diff --check "${base_ref}"..."${head_ref}"