Fix git mirror missing ref detection

This commit is contained in:
Codex Agent
2026-06-08 14:54:59 +08:00
parent 1657c84697
commit 8874f79b0b
+3 -3
View File
@@ -3568,7 +3568,7 @@ while read -r sha ref; do
if [ "$name" = "$gitops_branch" ]; then is_gitops_branch=true; break; fi
done
if [ "$is_gitops_branch" = true ]; then
local_sha=$(git -C "$repo_path" rev-parse "refs/heads/$name" 2>/dev/null || true)
local_sha=$(git -C "$repo_path" show-ref --verify --hash "refs/heads/$name" 2>/dev/null || true)
if [ -n "$local_sha" ] && [ "$local_sha" != "$sha" ]; then
if git -C "$repo_path" merge-base --is-ancestor "$sha" "$local_sha"; then
echo "git mirror sync keeps local $name ahead of GitHub"
@@ -3795,7 +3795,7 @@ chmod 0700 /tmp/hwlab-github-proxy-connect.mjs
export GIT_SSH_COMMAND="ssh -i /root/.ssh/id_rsa -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/root/.ssh/known_hosts -o ConnectTimeout=10 -o ServerAliveInterval=5 -o ServerAliveCountMax=1 -o ProxyCommand='node /tmp/hwlab-github-proxy-connect.mjs 127.0.0.1 10808 %h %p'"
/script/install-hooks.sh
for gitops_branch in ${gitopsBranchArgs}; do
local_head=$(git -C "$repo_path" rev-parse "refs/heads/$gitops_branch" 2>/dev/null || true)
local_head=$(git -C "$repo_path" show-ref --verify --hash "refs/heads/$gitops_branch" 2>/dev/null || true)
if [ -z "$local_head" ]; then
echo "git mirror flush skips missing local refs/heads/$gitops_branch"
continue
@@ -3803,7 +3803,7 @@ for gitops_branch in ${gitopsBranchArgs}; do
fetch_started=$(now_ms)
timeout 90 git -C "$repo_path" fetch --quiet "$repo_url" "refs/heads/$gitops_branch:refs/mirror-stage/heads/$gitops_branch"
emit_timing "fetch-$gitops_branch" succeeded "$fetch_started"
github_head=$(git -C "$repo_path" rev-parse "refs/mirror-stage/heads/$gitops_branch" 2>/dev/null || true)
github_head=$(git -C "$repo_path" show-ref --verify --hash "refs/mirror-stage/heads/$gitops_branch" 2>/dev/null || true)
if [ -n "$github_head" ] && [ "$github_head" != "$local_head" ] && ! git -C "$repo_path" merge-base --is-ancestor "$github_head" "$local_head"; then
echo "git mirror flush rejected divergent $gitops_branch local=$local_head github=$github_head" >&2
exit 52