repo: improve error handling for PR #4803

pull/4913/head
Unknwon 2018-03-08 07:22:14 -05:00
parent 1f7983059a
commit 63eaac67a6
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
1 changed files with 7 additions and 1 deletions

View File

@ -644,9 +644,15 @@ func viewIssue(c *context.Context, isPullList bool) {
pull := issue.PullRequest
branchProtected := false
protectBranch, err := models.GetProtectBranchOfRepoByName(pull.BaseRepoID, pull.HeadBranch)
if err == nil {
if err != nil {
if !errors.IsErrBranchNotExist(err) {
c.ServerError("GetProtectBranchOfRepoByName", err)
return
}
} else {
branchProtected = protectBranch.Protected
}
c.Data["IsPullBranchDeletable"] = pull.BaseRepoID == pull.HeadRepoID &&
c.Repo.IsWriter() && c.Repo.GitRepo.IsBranchExist(pull.HeadBranch) &&
!branchProtected