autopilot-code 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -207,6 +207,9 @@ if gh pr view --repo "$REPO" --head "$BRANCH" --json url --jq .url >/dev/null 2>
|
|
|
207
207
|
gh issue comment "$ISSUE_NUMBER" --repo "$REPO" --body "📋 PR already exists: $PR_URL" || true
|
|
208
208
|
else
|
|
209
209
|
PR_URL=$(gh pr create --repo "$REPO" --title "Autopilot: Issue #$ISSUE_NUMBER" --body "Closes #$ISSUE_NUMBER" --base main --head "$BRANCH")
|
|
210
|
+
|
|
211
|
+
# Add short delay after PR creation to allow GitHub to calculate merge state
|
|
212
|
+
sleep 10
|
|
210
213
|
fi
|
|
211
214
|
|
|
212
215
|
# 8. Comment on issue with PR URL (best-effort)
|
|
@@ -406,10 +409,45 @@ I'm monitoring the CI checks and will auto-merge once they pass. This may take a
|
|
|
406
409
|
while [[ $POLL_ATTEMPT -lt $MAX_POLL_ATTEMPTS ]]; do
|
|
407
410
|
POLL_ATTEMPT=$((POLL_ATTEMPT + 1))
|
|
408
411
|
|
|
409
|
-
# Get PR
|
|
410
|
-
|
|
412
|
+
# Get full PR status for debugging and decision making
|
|
413
|
+
PR_STATUS_JSON=$(gh pr view --repo "$REPO" --head "$BRANCH" --json mergeable,mergeStateStatus,statusCheckRollup 2>/dev/null || echo '{"mergeable":"UNKNOWN","mergeStateStatus":"UNKNOWN","statusCheckRollup":null}')
|
|
414
|
+
|
|
415
|
+
# Log raw API response for debugging
|
|
416
|
+
echo "[run_opencode_issue.sh] Debug: Raw PR status = $PR_STATUS_JSON"
|
|
417
|
+
|
|
418
|
+
# Parse mergeStateStatus
|
|
419
|
+
if command -v jq >/dev/null 2>&1; then
|
|
420
|
+
MERGE_STATE_STATUS=$(echo "$PR_STATUS_JSON" | jq -r '.mergeStateStatus')
|
|
421
|
+
else
|
|
422
|
+
MERGE_STATE_STATUS=$(python3 -c 'import json,sys; print(json.load(sys.stdin).get("mergeStateStatus", "UNKNOWN"))' <<<"$PR_STATUS_JSON")
|
|
423
|
+
fi
|
|
424
|
+
|
|
425
|
+
# Determine check status based on both statusCheckRollup and mergeStateStatus
|
|
426
|
+
# If mergeStateStatus is CLEAN or HAS_HOOKS and statusCheckRollup is null/empty → PASSED
|
|
427
|
+
# If mergeStateStatus is UNKNOWN → wait and retry
|
|
428
|
+
if [[ "$MERGE_STATE_STATUS" == "UNKNOWN" ]]; then
|
|
429
|
+
CHECK_STATUS="PENDING"
|
|
430
|
+
echo "[run_opencode_issue.sh] mergeStateStatus is UNKNOWN, waiting for GitHub to calculate..."
|
|
431
|
+
elif [[ "$MERGE_STATE_STATUS" == "CLEAN" || "$MERGE_STATE_STATUS" == "HAS_HOOKS" ]]; then
|
|
432
|
+
# Check statusCheckRollup - if null/empty, no checks configured, so PASSED
|
|
433
|
+
if command -v jq >/dev/null 2>&1; then
|
|
434
|
+
CHECK_STATUS=$(echo "$PR_STATUS_JSON" | jq -r '.statusCheckRollup | if . == null or length == 0 then "PASSED" elif map(.conclusion) | any(. == "FAILURE") then "FAILED" elif map(.conclusion) | any(. == "PENDING") or any(. == "QUEUED") then "PENDING" else "PASSED" end')
|
|
435
|
+
else
|
|
436
|
+
CHECK_STATUS=$(python3 -c 'import json,sys; data=json.load(sys.stdin); scr=data.get("statusCheckRollup"); print("PASSED" if not scr or len(scr)==0 else "FAILED" if any(c.get("conclusion")=="FAILURE" for c in scr) else "PENDING" if any(c.get("conclusion") in ["PENDING","QUEUED"] for c in scr) else "PASSED")' <<<"$PR_STATUS_JSON")
|
|
437
|
+
fi
|
|
438
|
+
elif [[ "$MERGE_STATE_STATUS" == "BLOCKED" ]]; then
|
|
439
|
+
# If mergeStateStatus is BLOCKED, check if it's due to failed checks
|
|
440
|
+
if command -v jq >/dev/null 2>&1; then
|
|
441
|
+
CHECK_STATUS=$(echo "$PR_STATUS_JSON" | jq -r '.statusCheckRollup | if . == null or length == 0 then "PASSED" elif map(.conclusion) | any(. == "FAILURE") then "FAILED" elif map(.conclusion) | any(. == "PENDING") or any(. == "QUEUED") then "PENDING" else "PASSED" end')
|
|
442
|
+
else
|
|
443
|
+
CHECK_STATUS=$(python3 -c 'import json,sys; data=json.load(sys.stdin); scr=data.get("statusCheckRollup"); print("PASSED" if not scr or len(scr)==0 else "FAILED" if any(c.get("conclusion")=="FAILURE" for c in scr) else "PENDING" if any(c.get("conclusion") in ["PENDING","QUEUED"] for c in scr) else "PASSED")' <<<"$PR_STATUS_JSON")
|
|
444
|
+
fi
|
|
445
|
+
else
|
|
446
|
+
# Other states (DRAFT, DIRTY, BEHIND) - mark as FAILED to exit
|
|
447
|
+
CHECK_STATUS="FAILED"
|
|
448
|
+
fi
|
|
411
449
|
|
|
412
|
-
echo "[run_opencode_issue.sh] Poll attempt $POLL_ATTEMPT/$MAX_POLL_ATTEMPTS: Check status = $CHECK_STATUS"
|
|
450
|
+
echo "[run_opencode_issue.sh] Poll attempt $POLL_ATTEMPT/$MAX_POLL_ATTEMPTS: Check status = $CHECK_STATUS, mergeStateStatus = $MERGE_STATE_STATUS"
|
|
413
451
|
|
|
414
452
|
if [[ "$CHECK_STATUS" == "PASSED" ]]; then
|
|
415
453
|
echo "[run_opencode_issue.sh] All checks passed. Proceeding with merge..."
|