2014-09-02 18:07:02 +05:30
|
|
|
module BranchesHelper
|
2016-08-24 12:49:21 +05:30
|
|
|
def filter_branches_path(options = {})
|
|
|
|
exist_opts = {
|
|
|
|
search: params[:search],
|
|
|
|
sort: params[:sort]
|
|
|
|
}
|
|
|
|
|
|
|
|
options = exist_opts.merge(options)
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
project_branches_path(@project, @id, options)
|
2016-08-24 12:49:21 +05:30
|
|
|
end
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
def can_push_branch?(project, branch_name)
|
2016-06-22 15:30:34 +05:30
|
|
|
return false unless project.repository.branch_exists?(branch_name)
|
2015-12-23 02:04:40 +05:30
|
|
|
|
2016-08-24 12:49:21 +05:30
|
|
|
::Gitlab::UserAccess.new(current_user, project: project).can_push_to_branch?(branch_name)
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
2016-06-16 23:09:34 +05:30
|
|
|
|
|
|
|
def project_branches
|
|
|
|
options_for_select(@project.repository.branch_names, @project.default_branch)
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
def protected_branch?(project, branch)
|
|
|
|
ProtectedBranch.protected?(project, branch.name)
|
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|