1
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-02-02 15:09:33 -05:00

When Deleting Repository only explicitly close PRs whose base is not this repository () ()

Backport 

When Deleting Repository only explicitly close PRs whose base is not this repository

Fix 

Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
zeripath 2021-03-02 13:44:14 +00:00 committed by GitHub
parent 4558eeb21a
commit d9d2e8f1e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -475,7 +475,7 @@ func CloseBranchPulls(doer *models.User, repoID int64, branch string) error {
return nil return nil
} }
// CloseRepoBranchesPulls close all pull requests which head branches are in the given repository // CloseRepoBranchesPulls close all pull requests which head branches are in the given repository, but only whose base repo is not in the given repository
func CloseRepoBranchesPulls(doer *models.User, repo *models.Repository) error { func CloseRepoBranchesPulls(doer *models.User, repo *models.Repository) error {
branches, err := git.GetBranchesByPath(repo.RepoPath()) branches, err := git.GetBranchesByPath(repo.RepoPath())
if err != nil { if err != nil {
@ -494,6 +494,11 @@ func CloseRepoBranchesPulls(doer *models.User, repo *models.Repository) error {
} }
for _, pr := range prs { for _, pr := range prs {
// If the base repository for this pr is this repository there is no need to close it
// as it is going to be deleted anyway
if pr.BaseRepoID == repo.ID {
continue
}
if err = issue_service.ChangeStatus(pr.Issue, doer, true); err != nil && !models.IsErrPullWasClosed(err) { if err = issue_service.ChangeStatus(pr.Issue, doer, true); err != nil && !models.IsErrPullWasClosed(err) {
errs = append(errs, err) errs = append(errs, err)
} }