Push whitelist now doesn't apply to branch deletion (#4601) (#4607)

This commit is contained in:
SagePtr 2018-08-08 05:17:11 +02:00 committed by Lunny Xiao
parent 67a8688538
commit 32145b6de8
2 changed files with 20 additions and 2 deletions

View file

@ -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