You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(amber): Push to existing PR instead of creating duplicates (#453)
When an issue already has an open PR, Amber now:
- Detects the existing PR via gh pr list search
- Checks out the existing branch instead of creating a new one
- Pushes additional commits to the existing PR
- Adds comments to both PR and issue about the update
This prevents duplicate PRs like #450, #442, #441, #438.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude <noreply@anthropic.com>
? `- Review that changes match the issue description\n- Verify no scope creep or unintended modifications\n- Changes pushed to existing PR #${existingPrNumber}`
432
+
: `- Review that changes match the issue description\n- Verify no scope creep or unintended modifications\n- A PR will be created shortly for formal review`;
433
+
315
434
await github.rest.issues.createComment({
316
435
owner: context.repo.owner,
317
436
repo: context.repo.repo,
318
437
issue_number: issueNumber,
319
-
body: `## Amber Change Summary\n\nThe following files were modified:\n\n\`\`\`\n${diff}\n\`\`\`\n\n**Next Steps:**\n- Review that changes match the issue description\n- Verify no scope creep or unintended modifications\n- A PR will be created shortly for formal review\n\n---\n🔍 [View AI decision process](${serverUrl}/${repository}/actions/runs/${runId}) (logs available for 90 days)`
438
+
body: `## Amber Change Summary\n\nThe following files were modified:\n\n\`\`\`\n${diff}\n\`\`\`\n\n**Next Steps:**\n${nextSteps}\n\n---\n🔍 [View AI decision process](${serverUrl}/${repository}/actions/runs/${runId}) (logs available for 90 days)`
// Add comment to PR about the new commit (with fallback)
519
+
await safeComment(
520
+
existingPrNumber,
521
+
`🤖 **Amber pushed additional changes**
522
+
523
+
- **Commit:** ${commitSha.substring(0, 7)}
524
+
- **Action Type:** ${actionType}
525
+
526
+
New changes have been pushed to this PR. Please review the updated code.
527
+
528
+
---
529
+
🔍 [View AI decision process](${serverUrl}/${repository}/actions/runs/${runId}) (logs available for 90 days)`,
530
+
`PR #${existingPrNumber} update notification`
531
+
);
532
+
533
+
// Also notify on the issue (with fallback)
534
+
await safeComment(
535
+
issueNumber,
536
+
`🤖 Amber pushed additional changes to the existing PR #${existingPrNumber}.\n\n---\n🔍 [View AI decision process](${serverUrl}/${repository}/actions/runs/${runId}) (logs available for 90 days)`,
console.log(`Warning: Failed to add labels to PR #${pr.data.number}: ${labelError.message}`);
590
+
}
415
591
416
-
// Link PR back to issue
417
-
await github.rest.issues.createComment({
418
-
owner: context.repo.owner,
419
-
repo: context.repo.repo,
420
-
issue_number: issueNumber,
421
-
body: `🤖 Amber has created a pull request to address this issue: #${pr.data.number}\n\nThe changes are ready for review. All automated checks will run on the PR.\n\n---\n🔍 [View AI decision process](${serverUrl}/${repository}/actions/runs/${runId}) (logs available for 90 days)`
422
-
});
592
+
// Link PR back to issue (with fallback)
593
+
await safeComment(
594
+
issueNumber,
595
+
`🤖 Amber has created a pull request to address this issue: #${pr.data.number}\n\nThe changes are ready for review. All automated checks will run on the PR.\n\n---\n🔍 [View AI decision process](${serverUrl}/${repository}/actions/runs/${runId}) (logs available for 90 days)`,
body: `⚠️ Amber completed changes but failed to create a pull request.\n\n**Error:** ${error.message}\n\nChanges committed to \`${branchName}\`. A maintainer can manually create the PR.`
435
-
});
601
+
console.error('Failed to create/update PR:', error);
// Notify on issue about failure (with fallback - best effort)
605
+
await safeComment(
606
+
issueNumber,
607
+
`⚠️ Amber completed changes but failed to create a pull request.\n\n**Error:** ${error.message}\n\nChanges committed to \`${branchName}\`. A maintainer can manually create the PR.`,
0 commit comments