From 8874f79b0ba85dc188d715f71b6aad13758c7dc1 Mon Sep 17 00:00:00 2001 From: Codex Agent Date: Mon, 8 Jun 2026 14:54:59 +0800 Subject: [PATCH] Fix git mirror missing ref detection --- scripts/g14-gitops-render.mjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/g14-gitops-render.mjs b/scripts/g14-gitops-render.mjs index 1d53e033..7b951796 100644 --- a/scripts/g14-gitops-render.mjs +++ b/scripts/g14-gitops-render.mjs @@ -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