aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-03-02 13:44:14 +0000
committerGitHub <noreply@github.com>2021-03-02 21:44:14 +0800
commitd9d2e8f1e840c990259d911c634780d1644233cd (patch)
treeefa20f4ff3e78495f4b1aa387c088ad0e0e81c83
parent4558eeb21a8249fc6d89d2b05d134bcfde6aaac6 (diff)
downloadgitea-d9d2e8f1e840c990259d911c634780d1644233cd.tar.gz
gitea-d9d2e8f1e840c990259d911c634780d1644233cd.zip
When Deleting Repository only explicitly close PRs whose base is not this repository (#14823) (#14842)
Backport #14823 When Deleting Repository only explicitly close PRs whose base is not this repository Fix #14775 Signed-off-by: Andrew Thornton <art27@cantab.net>
-rw-r--r--services/pull/pull.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/services/pull/pull.go b/services/pull/pull.go
index c3c9b9f930..0b753e4689 100644
--- a/services/pull/pull.go
+++ b/services/pull/pull.go
@@ -475,7 +475,7 @@ func CloseBranchPulls(doer *models.User, repoID int64, branch string) error {
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 {
branches, err := git.GetBranchesByPath(repo.RepoPath())
if err != nil {
@@ -494,6 +494,11 @@ func CloseRepoBranchesPulls(doer *models.User, repo *models.Repository) error {
}
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) {
errs = append(errs, err)
}