Skip to content

Refuse a Merged Branch Delete Where Another Open Pull Request Uses the Branch #2969

Closed

Description

@ptr727

Problem

Deleting a merged feature branch, by the hand form drive-pr and merge-and-release prescribe or by pr_review.py cleanup (#2967), can close another open pull request. A branch that is also the head of a second open pull request (into another base), or the base of a stacked one, passes every current check, since the tip still matches the merged pull request's headRefOid, and GitHub closes the other pull request when the branch goes.

Neither the skills nor the subcommand look for another open pull request on the branch before deleting it.

Proposed Fix

Before the delete, read the open pull requests whose head or base is that branch in the same repository, and refuse where any exists, naming them. cleanup exits 1 for that refusal, and the hand form in both skills gains the same check.

GitHub's "Restore branch" recovers a deleted head, so this is a recoverable gap rather than data loss, which is why it was filed rather than fixed in #2967.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions