From d2d0aea8a1440e54d35a9c2fb1c868071cd340d8 Mon Sep 17 00:00:00 2001 From: Wendell Sun Date: Fri, 23 Feb 2018 18:10:03 +0800 Subject: [PATCH] Fix the protected branch panic issue (#3567) --- models/branches.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/models/branches.go b/models/branches.go index d1921d550009..0a3d19858bbd 100644 --- a/models/branches.go +++ b/models/branches.go @@ -155,6 +155,10 @@ func (repo *Repository) GetProtectedBranches() ([]*ProtectedBranch, error) { // IsProtectedBranch checks if branch is protected func (repo *Repository) IsProtectedBranch(branchName string, doer *User) (bool, error) { + if doer == nil { + return true, nil + } + protectedBranch := &ProtectedBranch{ RepoID: repo.ID, BranchName: branchName,