summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorSagePtr <sageptr@gmail.com>2018-08-08 05:17:11 +0200
committerLunny Xiao <xiaolunwen@gmail.com>2018-08-08 11:17:10 +0800
commit32145b6de822c5e56424438902b70e1290310bba (patch)
treedaff3ecd8aa6f99b276a4433ad66dcd7d05a12ad /models
parent67a868853880c08bd4a6a6eca470bb4c475446da (diff)
downloadgitea-32145b6de822c5e56424438902b70e1290310bba.tar.gz
gitea-32145b6de822c5e56424438902b70e1290310bba.zip
Push whitelist now doesn't apply to branch deletion (#4601) (#4607)
Diffstat (limited to 'models')
-rw-r--r--models/branches.go18
1 files changed, 18 insertions, 0 deletions
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