2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
module BranchesHelper
|
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
|
2020-10-24 23:57:45 +05:30
|
|
|
|
|
|
|
def access_levels_data(access_levels)
|
|
|
|
return [] unless access_levels
|
|
|
|
|
|
|
|
access_levels.map do |level|
|
2021-01-29 00:20:46 +05:30
|
|
|
if level.type == :deploy_key
|
|
|
|
{ id: level.id, type: level.type, deploy_key_id: level.deploy_key_id }
|
|
|
|
else
|
|
|
|
{ id: level.id, type: :role, access_level: level.access_level }
|
|
|
|
end
|
2020-10-24 23:57:45 +05:30
|
|
|
end
|
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
|
|
|
BranchesHelper.prepend_if_ee('EE::BranchesHelper')
|