28 lines
1.7 KiB
Bash
28 lines
1.7 KiB
Bash
#!/usr/bin/env bash
|
||
# 合回验证点(远端 CI 触发钩子,2026-11-03 用户裁)——主工作区 git merge 落地后:
|
||
# ① push origin master(触发远端 CI:Gitea 收到 push → 派发 mac-ci runner 按改动域跑闸)
|
||
# ② 后台挂 ci_watch.sh remote 等回执(回执落 ci-status.json,agent 下次开工读态零改动)
|
||
# 推送失败=远端验证不可能发生——大声呈报并落 push_failed 判定进 ci-status.json(防静默,下游开工读态即见)。
|
||
# 任务 worktree 内的合并不触发(CI 只认 master);CI 红了不回滚合并——修复批合回后本钩子再推再验(追绿同链)。
|
||
set -u
|
||
_GD="$(cd "$(git rev-parse --git-dir)" && pwd)"
|
||
_CD="$(cd "$(git rev-parse --git-common-dir)" && pwd)"
|
||
[ "$_GD" = "$_CD" ] || exit 0
|
||
REPO="$(git rev-parse --show-toplevel)"
|
||
TIP="$(git -C "$REPO" rev-parse HEAD)"
|
||
export PYTHONIOENCODING=utf-8
|
||
if ! git -C "$REPO" push origin master >/dev/null 2>&1; then
|
||
echo "[post-merge] ✗ push origin master 失败——远端 CI 无法触发!先修推送(凭据/网络)后手动 git push,再手动挂 tools/ci_watch.sh remote $TIP"
|
||
python -I -c "
|
||
import json, os, datetime
|
||
p = r'$REPO/game/tests/.gates/ci-status.json'
|
||
d = {'commit': r'$TIP', 'verdict': 'push_failed', 'timestamp': datetime.datetime.now().astimezone().isoformat(timespec='seconds'),
|
||
'duration_s': 0, 'note': 'post-merge 推送失败,远端 CI 未触发——修复推送后手动 git push + ci_watch remote', 'red_gates': [], 'key_lines': []}
|
||
os.makedirs(os.path.dirname(p), exist_ok=True)
|
||
json.dump(d, open(p, 'w', encoding='utf-8'), ensure_ascii=False, indent=1)
|
||
" 2>/dev/null
|
||
exit 0
|
||
fi
|
||
( nohup bash "$REPO/tools/ci_watch.sh" remote "$TIP" >/dev/null 2>&1 & )
|
||
exit 0
|