@ -480,7 +480,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 ( ) , 0 , 0 )
branches , _ , err := git . GetBranchesByPath ( repo . RepoPath ( ) , 0 , 0 )
if err != nil {
if err != nil {
@ -499,6 +499,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 )
}
}