diff options
Diffstat (limited to 'app/helpers/gitlab/branches_helper.rb')
-rw-r--r-- | app/helpers/gitlab/branches_helper.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/helpers/gitlab/branches_helper.rb b/app/helpers/gitlab/branches_helper.rb new file mode 100644 index 00000000000..ecc56002e84 --- /dev/null +++ b/app/helpers/gitlab/branches_helper.rb @@ -0,0 +1,19 @@ +module Gitlab + module BranchesHelper + def can_remove_branch?(project, branch_name) + if project.protected_branch? branch_name + false + elsif branch_name == project.repository.root_ref + false + else + can?(current_user, :push_code, project) + end + end + + def can_push_branch?(project, branch_name) + return false unless project.repository.branch_names.include?(branch_name) + + ::Gitlab::GitAccess.new(current_user, project).can_push_to_branch?(branch_name) + end + end +end |