Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions scripts/push-current-arch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,21 @@ if [ -e "$WORKTREE_DIR" ]; then
git -C "$REPO_ROOT" worktree prune 2>/dev/null || true
fi

# Ensure the SHA is a local commit object before `git worktree add`.
# In CI, actions/checkout@v4 with default settings on a pull_request event
# fetches refs/pull/<N>/merge as a shallow clone. STARTUP_SHA_FULL
# (resolved above from .pull_request.head.sha) names the PR HEAD commit,
# which exists as a remote ref but NOT as a local object — so
# `git worktree add` fails with "fatal: invalid reference: <sha>".
# Empirical hit on PR #950 / issue #966 in rebuild-stale-arm64. Dev-
# machine path is unaffected: cat-file -e always succeeds on local HEAD.
if ! git -C "$REPO_ROOT" cat-file -e "$STARTUP_SHA_FULL^{commit}" 2>/dev/null; then
echo "→ SHA $STARTUP_SHA_FULL not present as a local object — fetching from origin"
git -C "$REPO_ROOT" fetch --depth 1 origin "$STARTUP_SHA_FULL" 2>/dev/null \
|| git -C "$REPO_ROOT" fetch origin "$STARTUP_SHA_FULL" 2>/dev/null \
|| { echo "ERROR: cannot fetch sha $STARTUP_SHA_FULL from origin (not a real commit, or network/auth issue)" >&2; exit 1; }
Comment on lines +220 to +222
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The git fetch ... 2>/dev/null redirects will hide the underlying failure reason in CI logs (auth vs ref not found vs network). Consider keeping stderr for at least the final fetch attempt, or capturing and re-printing it when both fetch attempts fail, to make failures diagnosable.

Suggested change
git -C "$REPO_ROOT" fetch --depth 1 origin "$STARTUP_SHA_FULL" 2>/dev/null \
|| git -C "$REPO_ROOT" fetch origin "$STARTUP_SHA_FULL" 2>/dev/null \
|| { echo "ERROR: cannot fetch sha $STARTUP_SHA_FULL from origin (not a real commit, or network/auth issue)" >&2; exit 1; }
FETCH_ERR_LOG="$(mktemp)"
if ! git -C "$REPO_ROOT" fetch --depth 1 origin "$STARTUP_SHA_FULL" 2>"$FETCH_ERR_LOG" \
&& ! git -C "$REPO_ROOT" fetch origin "$STARTUP_SHA_FULL" 2>>"$FETCH_ERR_LOG"; then
cat "$FETCH_ERR_LOG" >&2
rm -f "$FETCH_ERR_LOG"
echo "ERROR: cannot fetch sha $STARTUP_SHA_FULL from origin (not a real commit, or network/auth issue)" >&2
exit 1
fi
rm -f "$FETCH_ERR_LOG"

Copilot uses AI. Check for mistakes.
fi

echo "→ Creating frozen worktree at $WORKTREE_DIR (pinned at $STARTUP_SHA_FULL)"
git -C "$REPO_ROOT" worktree add --detach "$WORKTREE_DIR" "$STARTUP_SHA_FULL" >/dev/null

Expand Down
Loading