Skip to content

fix: retarget stack children before branch cleanup - #672

Merged
krasnoperov-coding-agent[bot] merged 2 commits into
mainfrom
feature/retarget-stack-children
Sep 14, 2026
Merged

krasnoperov-coding-agent[bot] merged 2 commits into
mainfrom
feature/retarget-stack-children

Conversation

@krasnoperov-coding-agent

Copy link
Copy Markdown
Contributor

Problem

Deleting a merged parent branch closes open stacked child PRs that still use that branch as their base.

Fix

Discover direct open children and retarget them to the merged parent's base before deleting the parent branch. If child discovery or retargeting fails, preserve the parent branch and defer cleanup.

Outcome

Declared PR stacks can land parent to child without losing the child PR, while unrelated PRs remain untouched.

@krasnoperov-coding-agent
krasnoperov-coding-agent Bot marked this pull request as ready for review September 14, 2026 19:22
review-quill[bot]
review-quill Bot previously requested changes Sep 14, 2026

@review-quill review-quill Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: 🛑 Request changes — Branch cleanup can still delete a base branch without discovering all current children.

if (merged) {
let children: Array<{ number: number; branch: string; headSha: string; baseBranch: string }>;
try {
children = (await ctx.github.listOpenPRs()).filter((pr) => pr.baseBranch === entry.branch);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚨 listOpenPRs() is capped at 1,000 results, so this treats an incomplete list as exhaustive. In repositories above that limit, an omitted child is not retargeted and is closed when its base branch is deleted; query children by base with complete pagination.

if (merged) {
let children: Array<{ number: number; branch: string; headSha: string; baseBranch: string }>;
try {
children = (await ctx.github.listOpenPRs()).filter((pr) => pr.baseBranch === entry.branch);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚨 Use the live branch returned by getStatus, not the queued entry.branch. If the parent branch was renamed after enqueue, children target the new name; this filter misses them and deletion closes those PRs.

@review-quill
review-quill Bot dismissed their stale review September 14, 2026 19:30

Superseded by newer head db8923b; review-quill will re-review the latest commit separately.

@review-quill review-quill Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: ✅ Approve — The newer head resolves both prior failure modes by querying all children for the live merged branch through paginated REST before cleanup. Failures still preserve the parent branch as scoped.

@krasnoperov-coding-agent krasnoperov-coding-agent Bot added queue:testing Merge-steward is validating speculative CI queue:merging Merge-steward is merging this PR and removed queue:testing Merge-steward is validating speculative CI labels Sep 14, 2026
@krasnoperov-coding-agent
krasnoperov-coding-agent Bot merged commit db8923b into main Sep 14, 2026
2 checks passed
@krasnoperov-coding-agent
krasnoperov-coding-agent Bot deleted the feature/retarget-stack-children branch September 14, 2026 19:36
@krasnoperov-coding-agent krasnoperov-coding-agent Bot removed the queue:merging Merge-steward is merging this PR label Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants