Skip to content

Commit 9a22e58

Browse files
committed
When Deleting Repository only explicitly close PRs whose base is not this repository (go-gitea#14823)
Backport go-gitea#14823 When Deleting Repository only explicitly close PRs whose base is not this repository Fix go-gitea#14775 Signed-off-by: Andrew Thornton <[email protected]>
1 parent 4558eeb commit 9a22e58

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

services/pull/pull.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ func CloseBranchPulls(doer *models.User, repoID int64, branch string) error {
475475
return nil
476476
}
477477

478-
// CloseRepoBranchesPulls close all pull requests which head branches are in the given repository
478+
// CloseRepoBranchesPulls close all pull requests which head branches are in the given repository, but only whose base repo is not in the given repository
479479
func CloseRepoBranchesPulls(doer *models.User, repo *models.Repository) error {
480480
branches, err := git.GetBranchesByPath(repo.RepoPath())
481481
if err != nil {
@@ -494,6 +494,11 @@ func CloseRepoBranchesPulls(doer *models.User, repo *models.Repository) error {
494494
}
495495

496496
for _, pr := range prs {
497+
// If the base repository for this pr is this repository there is no need to close it
498+
// as it is going to be deleted anyway
499+
if pr.BaseRepoID == repo.ID {
500+
continue
501+
}
497502
if err = issue_service.ChangeStatus(pr.Issue, doer, true); err != nil && !models.IsErrPullWasClosed(err) {
498503
errs = append(errs, err)
499504
}

0 commit comments

Comments
 (0)