From 4eff6927a7293498ff0be6abd45ac4b7c7ccc1ee Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Sat, 27 Feb 2021 21:24:58 +0000 Subject: [PATCH 1/3] When Deleting Repository only explicitly close PRs whose base is not this repository Fix #14775 Signed-off-by: Andrew Thornton --- services/pull/pull.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/pull/pull.go b/services/pull/pull.go index 4f742f5a1a6a8..cb86b4e172743 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -480,7 +480,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 whose base repo is not in the given repository func CloseRepoBranchesPulls(doer *models.User, repo *models.Repository) error { branches, _, err := git.GetBranchesByPath(repo.RepoPath(), 0, 0) if err != nil { @@ -499,6 +499,9 @@ func CloseRepoBranchesPulls(doer *models.User, repo *models.Repository) error { } for _, pr := range prs { + if pr.BaseRepoID == repo.ID { + continue + } if err = issue_service.ChangeStatus(pr.Issue, doer, true); err != nil && !models.IsErrPullWasClosed(err) { errs = append(errs, err) } From 59807a07e5ea0b6e85419fc1e59d63467dbdc882 Mon Sep 17 00:00:00 2001 From: zeripath Date: Sun, 28 Feb 2021 16:34:17 +0000 Subject: [PATCH 2/3] as per @noerw --- services/pull/pull.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/pull/pull.go b/services/pull/pull.go index cb86b4e172743..20ab43643533c 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -499,6 +499,8 @@ 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 } From 4ff513858e61418be37409d3a7c1eecc94b1b0f3 Mon Sep 17 00:00:00 2001 From: zeripath Date: Mon, 1 Mar 2021 04:55:14 +0000 Subject: [PATCH 3/3] Update services/pull/pull.go Co-authored-by: 6543 <6543@obermui.de> --- services/pull/pull.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/pull/pull.go b/services/pull/pull.go index 20ab43643533c..cadb317472ddb 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -480,7 +480,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, but whose base repo is not 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(), 0, 0) if err != nil {