Skip to content

Deleting a branch breaks all PRs with this branch as target #19190

Closed
@delvh

Description

@delvh

Description

Currently, when you delete a branch, all PRs still targeting this branch will be closed forever, breaking them completely if you intend to merge them into another branch, i.e. the target branch of a PR that deleted the branch.
The result of this bug is that even if you attempt to reopen such a PR, you simply won't be able to:
The PR cannot be reopened because the branch does not exist, and the branch can't be changed because the PR is closed.

Reproduction Steps

  1. Create the first branch with some changes
  2. Create the second branch with more changes from the first branch
  3. Open PRs in both branches, with the first branch targeting anything, and the second branch targeting the first branch
  4. Merge the PR of the first branch, making sure to delete the first branch with it
  5. Enjoy the second PR being broken

Reproduction PR: https://try.gitea.io/delvh/kanban-test/pulls/23

Possible Solutions

  • Allow changing the target branches for closed (but not merged?) PRs (most likely solution)
  • Allow (re)opening PRs whose target branch is missing (unlikely, leads to too many errors)
  • Automatically change the target of such PRs to the target of the closing branch (unlikely, works only in the reproduction setup, and is somewhat counter-intuitive for a user)

Gitea Version

1.16.4 to 1.17.0+dev-327-gf7883a6ae

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

image
(The red box in this case comes from trying to edit the target branch to reopen the PR)

Git Version

No response

Operating System

No response

How are you running Gitea?

try.gitea.io

Database

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue/needs-feedbackFor bugs, we need more details. For features, the feature must be described in more detailtype/bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions