Explorar el Código

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

tags/v1.6.0-dev
SagePtr hace 5 años
padre
commit
32145b6de8
Se han modificado 2 ficheros con 20 adiciones y 2 borrados
  1. 18
    0
      models/branches.go
  2. 2
    2
      modules/context/repo.go

+ 18
- 0
models/branches.go Ver fichero

BranchName: branchName, 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) has, err := x.Get(protectedBranch)
if err != nil { if err != nil {
return true, err return true, err

+ 2
- 2
modules/context/repo.go Ver fichero

} }


// CanCommitToBranch returns true if repository is editable and user has proper access level // CanCommitToBranch returns true if repository is editable and user has proper access level
// and branch is not protected
// and branch is not protected for push
func (r *Repository) CanCommitToBranch(doer *models.User) (bool, error) { func (r *Repository) CanCommitToBranch(doer *models.User) (bool, error) {
protectedBranch, err := r.Repository.IsProtectedBranch(r.BranchName, doer)
protectedBranch, err := r.Repository.IsProtectedBranchForPush(r.BranchName, doer)
if err != nil { if err != nil {
return false, err return false, err
} }

Cargando…
Cancelar
Guardar