Skip to content

Commit e726e4b

Browse files
jonasfranztechknowlogick
authored andcommitted
Add base repo nil check (#5555)
Signed-off-by: Jonas Franz <[email protected]>
1 parent 8730ee0 commit e726e4b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

models/pull.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,15 @@ func (pr *PullRequest) loadIssue(e Engine) (err error) {
113113

114114
// LoadProtectedBranch loads the protected branch of the base branch
115115
func (pr *PullRequest) LoadProtectedBranch() (err error) {
116+
if pr.BaseRepo == nil {
117+
if pr.BaseRepoID == 0 {
118+
return nil
119+
}
120+
pr.BaseRepo, err = GetRepositoryByID(pr.BaseRepoID)
121+
if err != nil {
122+
return
123+
}
124+
}
116125
pr.ProtectedBranch, err = GetProtectedBranchBy(pr.BaseRepo.ID, pr.BaseBranch)
117126
return
118127
}

0 commit comments

Comments
 (0)