summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorWendell Sun <iwendellsun@gmail.com>2018-02-23 18:10:03 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2018-02-23 18:10:03 +0800
commitd2d0aea8a1440e54d35a9c2fb1c868071cd340d8 (patch)
treea367a0c1ee59b8ed590d4630b2d19fe8765386fa /models
parent2d1c5c3756beab3dfb3a1463d601385ab2e5db6f (diff)
downloadgitea-d2d0aea8a1440e54d35a9c2fb1c868071cd340d8.tar.gz
gitea-d2d0aea8a1440e54d35a9c2fb1c868071cd340d8.zip
Fix the protected branch panic issue (#3567)
Diffstat (limited to 'models')
-rw-r--r--models/branches.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/models/branches.go b/models/branches.go
index d1921d5500..0a3d19858b 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,