From 32145b6de822c5e56424438902b70e1290310bba Mon Sep 17 00:00:00 2001 From: SagePtr Date: Wed, 8 Aug 2018 05:17:11 +0200 Subject: Push whitelist now doesn't apply to branch deletion (#4601) (#4607) --- models/branches.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'models/branches.go') diff --git a/models/branches.go b/models/branches.go index ade5de8e0e..3de76a5cc1 100644 --- a/models/branches.go +++ b/models/branches.go @@ -184,6 +184,24 @@ func (repo *Repository) IsProtectedBranch(branchName string, doer *User) (bool, BranchName: branchName, } + has, err := x.Exist(protectedBranch) + if err != nil { + return true, err + } + return has, nil +} + +// IsProtectedBranchForPush checks if branch is protected for push +func (repo *Repository) IsProtectedBranchForPush(branchName string, doer *User) (bool, error) { + if doer == nil { + return true, nil + } + + protectedBranch := &ProtectedBranch{ + RepoID: repo.ID, + BranchName: branchName, + } + has, err := x.Get(protectedBranch) if err != nil { return true, err -- cgit v1.2.3