fd423770d8
修复 Agent 失败展示变更中的 import 排序错误 统一 CI 与 master pre-push 的 Repository checks 入口 让 staged JS 和 TS 自动执行 ESLint 修复与 Prettier 补充部分暂存、忽略文件和待推 SHA 回归测试 同步分支保护与本地门禁流程文档
43 lines
1.4 KiB
Bash
Executable File
43 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
set -euo pipefail
|
||
|
||
remote_name="${1:-origin}"
|
||
remote_url="${2:-}"
|
||
master_update=false
|
||
master_local_sha=''
|
||
master_remote_sha=''
|
||
|
||
while read -r local_ref local_sha remote_ref remote_sha; do
|
||
if [[ "${remote_ref}" == 'refs/heads/master' && "${local_sha}" != '0000000000000000000000000000000000000000' ]]; then
|
||
master_update=true
|
||
master_local_sha="${local_sha}"
|
||
master_remote_sha="${remote_sha}"
|
||
fi
|
||
done
|
||
|
||
if [[ "${master_update}" != true ]]; then
|
||
exit 0
|
||
fi
|
||
|
||
if [[ -z "${master_remote_sha}" || "${master_remote_sha}" == '0000000000000000000000000000000000000000' ]]; then
|
||
master_remote_sha="$(git rev-parse "refs/remotes/${remote_name}/master" 2>/dev/null || true)"
|
||
fi
|
||
|
||
if [[ -z "${master_remote_sha}" ]]; then
|
||
echo "[pre-push] 无法确定 ${remote_name}/master 比较基线;remote=${remote_url:-unknown}" >&2
|
||
exit 1
|
||
fi
|
||
|
||
if [[ "$(git rev-parse HEAD)" != "${master_local_sha}" ]]; then
|
||
echo '[pre-push] master 待推提交不是当前 HEAD,无法对候选内容执行可靠门禁。' >&2
|
||
exit 1
|
||
fi
|
||
|
||
if ! git diff --quiet || ! git diff --cached --quiet; then
|
||
echo '[pre-push] 工作树或暂存区存在已跟踪改动,无法保证检查内容与 master 待推提交一致。' >&2
|
||
exit 1
|
||
fi
|
||
|
||
echo "[pre-push] 推送 master,执行 Repository checks;base=${master_remote_sha}"
|
||
npm run check:repository-ci -- "${master_remote_sha}" "${master_local_sha}"
|