Repository navigation
Delete merged worktrees: count PRs merged into a stack parent or release branch #24108
leomontigatti
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Follow-up to #14758, which was closed with a pointer to Ideas.
The problem
I work in stacked PRs: each layer's PR targets the branch of the layer below it, not
main. When a layer merges into its parent, Delete merged worktrees keeps its worktree.storageCleanupPullRequestMerged(apps/server/src/storageCleanup.ts) accepts a merged PR only whenpullRequest.baseRef === worktree.defaultBranch(or when the head is already in the default branch). So a layer's worktree waits until the whole stack lands inmain, and with a squash merge of the parent it waits forever. Today I clean these up by hand.Proposal
Count a PR as merged for cleanup whatever its base branch is, as long as the host says it is
mergedand itsheadRefandheadShamatch the worktree's branch and head. That is the exact-head check cleanup already makes for squash merges into the default branch, minus the base-branch condition.I think this is safe for the same reason the squash case is: cleanup keeps the local branch (and T3 recreates the checkout from it on resume), and the commits now live on the parent's branch on the remote. Removing the worktree loses no work. If an unrestricted base feels too broad, an opt-in (for example a "PRs merged into any branch" switch under Storage) would cover it too.
A related case with the same fix: a PR that targets a release branch that hasn't been merged back into
mainyet.All reactions