-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Redirect open PRs when the target branch is deleted through merging a PR #28539
Conversation
… as a result of the PR merge
Looks like a duplicate of #18478 to me, but with a slightly simpler implementation |
@denyskon , thx for reply. |
This implementation looks clean. I will try to test it out during the next few days :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to my tests, this feature seems to work great, and the implementation is a lot simpler than in the linked PR 👍
Co-authored-by: Denys Konovalov <kontakt@denyskon.de>
Co-authored-by: Denys Konovalov <kontakt@denyskon.de>
Hello @denyskon. Thanks for the review. I apologize for making changes after the review. |
routers/web/repo/pull.go
Outdated
pullRequestsToHead, err := issues_model.GetUnmergedPullRequestsByBaseInfo(ctx, pr.HeadRepoID, pr.HeadBranch) | ||
if err != nil { | ||
ctx.ServerError("GetUnmergedPullRequestsByBaseInfo", err) | ||
return | ||
} | ||
|
||
for _, prToHead := range pullRequestsToHead { | ||
if prToHead.BaseRepoID != pr.BaseRepoID { | ||
continue | ||
} | ||
|
||
if err := prToHead.LoadIssue(ctx); err != nil { | ||
ctx.ServerError(fmt.Sprintf("LoadIssueForPullRequest[%d]", prToHead.ID), err) | ||
return | ||
} | ||
|
||
if prToHead.Issue.RepoID == pr.Issue.RepoID { | ||
prToHead.Issue.Repo = pr.Issue.Repo | ||
} else { | ||
if err := prToHead.Issue.LoadRepo(ctx); err != nil { | ||
ctx.ServerError(fmt.Sprintf("LoadRepoForIssue[%d]", prToHead.IssueID), err) | ||
return | ||
} | ||
} | ||
|
||
if err := pull_service.ChangeTargetBranch(ctx, prToHead, ctx.Doer, pr.BaseBranch); err != nil { | ||
ctx.ServerError(fmt.Sprintf("ChangeTargetBranch[%d]", prToHead.ID), err) | ||
return | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we please extract this code into a new subfunction?
Something like redirectOpenPulls
or so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a good idea. This will allow you to use redirection in the API, as @kvaster noted.
Also, I'm currently wondering how edge cases will behave.
The owner of |
@delvh According to A fork of a private repository remains private. So how should |
I think that this PR is almost the same as mine (#18478), but it covers even less when mine: This PR covers only And also both PRs do not cover following case: Repo What should happen in case
|
So, I think, that we should:
|
The PR was complete from my point of view. Probably nobody cared about it and I had no time/wish to push this topic. I was just updating PR from time to time. Also I had no time (no experiance in go) to write unit tests for it. |
To me, it doesn't matter which PR is merged in the end. As it already has two approvals, it would maybe happen faster here, but I'm also open to reviewing the other PR if needed. I'd say we need the functionality for the API, which can easily be provided by the function that delvh suggested to add. As for the example you brought up, I don't think we should retarget these PRs as it would basically mean that PRs end up in a repo they maybe weren't intended to, without the author even being notified about it. (cc @tulzke) |
@denyskon, to me it always metters if someone is spending his time to help. I already wrote my concerns about current status of this PR:
|
This is not a competition. I really want this feature to be merged aswell. I' ve reopened my PR in case somebody will want to make a review. |
I don't think redirecting PR to other repositories is a good idea.
The error is being checked. Why did you decide that this was not the case? |
@delvh in your case PR will be closed. The current behavior remained in place. If the PR has not been redirected to another branch, it will be closed. |
@tulzke, seems I've missed - you're really checking if base repo is the same. For error checking -
Also
both should be covered Also As I said before - I really don't know why we should go through this once again. |
…ranch. Added function call to api/v1
In the end, I don't care which PR is merged. I just want to see this feature in the next minor release. I took the logic out into a separate function, and also added a call to the api. It doesn't make sense to check these two errors, because we only work with open PRS:
|
@tulzke, my thoughts about Also what do you think about |
Yes, i added redirect to
I think you're right. @denyskon @delvh @a1012112796 Can we review @kvaster's proposed PR? It looks like everything is ready there. |
Okay, I think we can agree on closing this in favor of #28686.... |
Good news, thanks |
Added a change the destination branch for those pull requests whose destination branch was deleted as a result of merge.
PR's HEAD changes to HEAD of the merged PR.
Resolves #27062