diff --git a/models/branches.go b/models/branches.go index 7cc0ebab4..bf5d4fdb4 100644 --- a/models/branches.go +++ b/models/branches.go @@ -156,6 +156,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,