Skip to content

Commit e440560

Browse files
Antigravity Agentclaude
andcommitted
fix(cloud): false-FAILED bug + stale bare repo — 2 entrypoint fixes
Bug #20: When Claude Code creates PR directly via gh pr create, COMMIT_COUNT is never set, causing false FAILED status even though PR exists. Fix: count commits when PR already exists, report DONE. Bug #21: Bare repo worktree uses stale main ref from Docker prebake. git fetch updates origin/main but not local main. Fix: git update-ref after fetch to sync local main to origin/main. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e8e06b7 commit e440560

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

deploy/agent-entrypoint.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,8 @@ else
400400
log "Updating bare repo from remote..."
401401
cd /bare-repo.git
402402
retry "git fetch origin main --depth=50 2>/dev/null" || log "Warning: bare repo update failed"
403+
# Update local main ref to match remote (bare repo has stale pre-baked main)
404+
git update-ref refs/heads/main origin/main 2>/dev/null || log "Warning: could not update main ref"
403405
fi
404406

405407
# Create worktree for this agent (fast! ~5-10s vs ~60s for full clone)
@@ -602,13 +604,19 @@ ${DIFF_STAT}
602604
gh issue comment "${ISSUE}" --repo "${GH_REPO}" --body "❌ **Trinity Agent**: No solution produced. Issue may need manual attention." 2>/dev/null || true
603605
fi
604606
else
605-
stream_to_telegram "PR already exists: #${EXISTING_PR}"
607+
# Claude Code already created and pushed a PR — count commits on the branch
608+
COMMIT_COUNT=$(git log --oneline main..HEAD 2>/dev/null | wc -l | tr -d ' ')
609+
stream_to_telegram "PR already exists: #${EXISTING_PR} (${COMMIT_COUNT} commits on branch)"
610+
report_status "PR_CREATED" "PR #${EXISTING_PR} already exists"
606611
fi
607612

608613
# === 8. Report final status ===
609614
if [ "${CLAUDE_EXIT}" -eq 0 ] && [ "${COMMIT_COUNT:-0}" -gt 0 ]; then
610615
report_status "DONE" "PR created with ${COMMIT_COUNT} commits"
611616
send_telegram "✅ Agent #${ISSUE}: DONE — ${COMMIT_COUNT} commits, PR created"
617+
elif [ "${CLAUDE_EXIT}" -eq 0 ] && [ -n "${EXISTING_PR}" ]; then
618+
report_status "DONE" "PR #${EXISTING_PR} created by Claude Code"
619+
send_telegram "✅ Agent #${ISSUE}: DONE — PR #${EXISTING_PR} created"
612620
elif [ "${CLAUDE_EXIT}" -eq 124 ]; then
613621
: # already reported STUCK
614622
else

0 commit comments

Comments
 (0)