Do not allow commiting to protected branch from online editor (#1502)
* Do not allow commiting to protected branch from online editor * Add editor integration tests for adding new file and not allowing to add new file to protected branch
This commit is contained in:
parent
3ebbdfaa75
commit
0144817971
10 changed files with 386 additions and 15 deletions
|
@ -75,6 +75,16 @@ func (r *Repository) CanEnableEditor() bool {
|
|||
return r.Repository.CanEnableEditor() && r.IsViewBranch && r.IsWriter()
|
||||
}
|
||||
|
||||
// CanCommitToBranch returns true if repository is editable and user has proper access level
|
||||
// and branch is not protected
|
||||
func (r *Repository) CanCommitToBranch() (bool, error) {
|
||||
protectedBranch, err := r.Repository.IsProtectedBranch(r.BranchName)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return r.CanEnableEditor() && !protectedBranch, nil
|
||||
}
|
||||
|
||||
// GetEditorconfig returns the .editorconfig definition if found in the
|
||||
// HEAD of the default repo branch.
|
||||
func (r *Repository) GetEditorconfig() (*editorconfig.Editorconfig, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue