Skip to content
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

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

Merged
7 changes: 6 additions & 1 deletion services/pull/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 only whose base repo is not in the given repository
func CloseRepoBranchesPulls(doer *models.User, repo *models.Repository) error {
6543 marked this conversation as resolved.
Show resolved Hide resolved
branches, _, err := git.GetBranchesByPath(repo.RepoPath(), 0, 0)
if err != nil {
Expand All @@ -499,6 +499,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 {
zeripath marked this conversation as resolved.
Show resolved Hide resolved
continue
}
if err = issue_service.ChangeStatus(pr.Issue, doer, true); err != nil && !models.IsErrPullWasClosed(err) {
errs = append(errs, err)
}
Expand Down