aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWendell Sun <iwendellsun@gmail.com>2018-02-24 01:27:34 +0800
committerLauris BH <lauris@nix.lv>2018-02-23 19:27:34 +0200
commitd87fb0a6fd6154ac7810c27b02bcbfc52e850460 (patch)
tree939b242d4779f4dbf62fa3f5710491f26401c061
parente55eaa8545a87dcbcc511d1e4acb1f0398d252dd (diff)
downloadgitea-d87fb0a6fd6154ac7810c27b02bcbfc52e850460.tar.gz
gitea-d87fb0a6fd6154ac7810c27b02bcbfc52e850460.zip
Fix the protected branch panic issue (#3567) (#3569)
Signed-off-by: Wendell Sun <iwendellsun@gmail.com>
-rw-r--r--models/branches.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/models/branches.go b/models/branches.go
index 7cc0ebab4d..bf5d4fdb49 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,