Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
delvh opened this issue Mar 23, 2022 · 11 comments
Closed

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

delvh opened this issue Mar 23, 2022 · 11 comments
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail type/bug

Comments

@delvh
Copy link
Member

delvh commented Mar 23, 2022

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

@delvh delvh added the type/bug label Mar 23, 2022
@delvh delvh added this to the 1.17.0 milestone Mar 23, 2022
@lunny
Copy link
Member

lunny commented Mar 25, 2022

This is an enhancement rather than a bug imo.

@delvh
Copy link
Member Author

delvh commented Mar 25, 2022

I'd absolutely say that this is a bug since no one expects that it will be forever impossible to reopen a PR.
A dead unmerged PR is in my opinion absolutely a bug.
The only workaround for this is to explicitly visit the base branch of the dead PR and click on New Pull Request, which loses all previous data from the PR such as worked times, comments and other metadata.
All in all a pretty work-intensive bug once it occurs.

@lunny
Copy link
Member

lunny commented Oct 21, 2022

What's the behaviors of Github or GitLab?

@lunny
Copy link
Member

lunny commented Oct 24, 2022

What's the behaviors of Github or GitLab?

I just have tested. Github also will not support change a closed PR's target branch. So I think this should not be a bug but a proposal.

@lunny lunny modified the milestones: 1.18.0, 1.19.0 Oct 24, 2022
@rudolphfroger
Copy link

rudolphfroger commented Jan 25, 2023

Another solution is to not allow merging a PR for a branch which is the target branch for other PRs. For me that would be the most correct and explicit option since it seems weird that you can merge PR that others depend on.

If it would work like this then people would first need to change the target branch for other PRs before they can merge the PR which was the target for them. That way PRs aren't closed automatically anymore, and it's clear what is happening for everyone.

@lunny lunny modified the milestones: 1.19.0, 1.20.0 Feb 3, 2023
@delvh delvh removed this from the 1.20.0 milestone Jun 5, 2023
@flyasky
Copy link

flyasky commented Jun 13, 2023

What's the behaviors of Github or GitLab?

Gitlab preserves PRs if the original branch (to which we are targeting this PR) is merged. You have an option to retarget dependent branch into develop.

When you work within big team with multiple branches started from unmerged one and targeted to this one, You will got into the situation when all dependent PRs are closed, review comments are in the closed PRs. It's just a good reason to switch to gitlab.

@flyasky
Copy link

flyasky commented Jun 13, 2023

What's the behaviors of Github or GitLab?

I just have tested. Github also will not support change a closed PR's target branch. So I think this should not be a bug but a proposal.

Gitea is autoclosing PRs if target branch is deleted (original PR is merged). This auto operation has to be avoided.

@lunny
Copy link
Member

lunny commented Jun 14, 2023

Yes, maybe we need a confirmation dialogue and list all pull requests which target branch is it.

@jtran
Copy link
Contributor

jtran commented Oct 18, 2023

To allow stacked PRs, if the target branch A is deleted due to being merged into another branch B, then the stacked PR should get automatically retargeted to B.

GitHub has been doing this since 2020. Stacking PRs is a pretty common use case, and it would resolve many instances of running into this problem. I'm guessing the vast majority of cases.

@jtran
Copy link
Contributor

jtran commented May 20, 2024

Is this resolved by #28686?

@lunny lunny added the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label May 22, 2024
@GiteaBot
Copy link
Contributor

We close issues that need feedback from the author if there were no new comments for a month. 🍵

@go-gitea go-gitea locked as resolved and limited conversation to collaborators Sep 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail type/bug
Projects
None yet
Development

No branches or pull requests

6 participants