diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-12-08 16:42:10 +0100 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-12-08 16:42:10 +0100 |
commit | df6750d3d6b562c8a6a0a57c12dfd694da38a0e8 (patch) | |
tree | 54f15d83ddef9b524144cf6c49385b5e98c96509 /app/helpers/tree_helper.rb | |
parent | 792f2bbe0b306bda266dfc817edf33b4c9e36a0f (diff) | |
download | gitlab-ce-df6750d3d6b562c8a6a0a57c12dfd694da38a0e8.tar.gz |
Default target branch to patch-n when editing file in protected branch
Diffstat (limited to 'app/helpers/tree_helper.rb')
-rw-r--r-- | app/helpers/tree_helper.rb | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb index 6afa1aacc5b..ac75c9a14b7 100644 --- a/app/helpers/tree_helper.rb +++ b/app/helpers/tree_helper.rb @@ -48,10 +48,17 @@ module TreeHelper def allowed_tree_edit?(project = nil, ref = nil) project ||= @project - ref ||= @ref - return false unless project.repository.branch_names.include?(ref) + can?(current_user, :push_code, project) + end - ::Gitlab::GitAccess.new(current_user, project).can_push_to_branch?(ref) + def tree_edit_branch(project = @project, ref = @ref) + if allowed_tree_edit? + if can_push_branch?(project, ref) + ref + else + project.repository.next_patch_branch + end + end end def can_delete_or_replace?(blob) |