summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorSagePtr <sageptr@gmail.com>2018-08-08 10:19:13 +0200
committerLauris BH <lauris@nix.lv>2018-08-08 11:19:13 +0300
commit15a403bf976dee832edacd8b7b65a8f808df427c (patch)
treebcd9aff287756baa02fb07e4ac885fb6ae4bef64 /models
parent099028681ea6d0345af7bf1d80feb02041f1f4cc (diff)
downloadgitea-15a403bf976dee832edacd8b7b65a8f808df427c.tar.gz
gitea-15a403bf976dee832edacd8b7b65a8f808df427c.zip
Push whitelist now doesn't apply to branch deletion (#4601) (#4640)
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