From e726e4b828e9592085e6cf717a2e6c29b1c2d472 Mon Sep 17 00:00:00 2001 From: Jonas Franz Date: Mon, 17 Dec 2018 18:35:21 +0100 Subject: [PATCH] Add base repo nil check (#5555) Signed-off-by: Jonas Franz --- models/pull.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/models/pull.go b/models/pull.go index 0d8886186e3a..4c4c3f3e1e76 100644 --- a/models/pull.go +++ b/models/pull.go @@ -113,6 +113,15 @@ func (pr *PullRequest) loadIssue(e Engine) (err error) { // LoadProtectedBranch loads the protected branch of the base branch func (pr *PullRequest) LoadProtectedBranch() (err error) { + if pr.BaseRepo == nil { + if pr.BaseRepoID == 0 { + return nil + } + pr.BaseRepo, err = GetRepositoryByID(pr.BaseRepoID) + if err != nil { + return + } + } pr.ProtectedBranch, err = GetProtectedBranchBy(pr.BaseRepo.ID, pr.BaseBranch) return }