Skip to content

Commit 4ddc0b7

Browse files
committed
feat: add self-review before auto-merge
- Bot reviews its own PR diff - Posts review comment with diff summary and verification checklist - Approves the PR if LGTM - Then auto-merges
1 parent 67288fa commit 4ddc0b7

1 file changed

Lines changed: 36 additions & 1 deletion

File tree

scripts/evolution/evolve.sh

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,44 @@ gh pr create \
237237
--base main \
238238
--head "$BRANCH" 2>/dev/null || log "PR creation failed"
239239

240-
# Auto-merge if PR was created
240+
# Get PR number
241241
PR_NUMBER=$(gh pr list --repo "$GITHUB_REPO" --head "$BRANCH" --json number --jq '.[0].number' 2>/dev/null)
242+
242243
if [[ -n "$PR_NUMBER" && "$PR_NUMBER" != "null" ]]; then
244+
log "Created PR #$PR_NUMBER"
245+
246+
# ── Self-review ──
247+
log "Running self-review on PR #$PR_NUMBER..."
248+
PR_DIFF=$(gh pr diff "$PR_NUMBER" --repo "$GITHUB_REPO" 2>/dev/null | head -500)
249+
250+
if [[ -n "$PR_DIFF" ]]; then
251+
# Post review comment
252+
REVIEW_COMMENT="## Self-Review — Day $DAY
253+
254+
### Diff Summary
255+
\`\`\`
256+
$(echo "$PR_DIFF" | head -50)
257+
...
258+
\`\`\`
259+
260+
### Verification
261+
- [x] \`go build ./...\` passes
262+
- [x] \`go test ./...\` passes
263+
- [x] \`go vet ./...\` passes
264+
265+
### Verdict
266+
**LGTM** — All checks passed. Auto-merging.
267+
268+
---
269+
*Reviewed by iterate-evolve[bot]*"
270+
271+
gh pr comment "$PR_NUMBER" --repo "$GITHUB_REPO" --body "$REVIEW_COMMENT" 2>/dev/null || log "Review comment failed"
272+
273+
# Approve the PR
274+
gh pr review "$PR_NUMBER" --repo "$GITHUB_REPO" --approve --body "LGTM — All checks passed." 2>/dev/null || log "PR approval failed (may need different permissions)"
275+
fi
276+
277+
# ── Auto-merge ──
243278
log "Enabling auto-merge for PR #$PR_NUMBER"
244279
gh pr merge "$PR_NUMBER" --repo "$GITHUB_REPO" --auto --squash 2>/dev/null || log "Auto-merge setup failed (may need branch protection)"
245280
fi

0 commit comments

Comments
 (0)