2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
module ProtectedBranches
|
|
|
|
class ApiService < BaseService
|
|
|
|
def create
|
2019-07-07 11:18:12 +05:30
|
|
|
::ProtectedBranches::CreateService.new(@project, @current_user, protected_branch_params).execute
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
def protected_branch_params
|
|
|
|
{
|
2018-03-17 18:26:18 +05:30
|
|
|
name: params[:name],
|
2021-04-17 20:07:23 +05:30
|
|
|
allow_force_push: allow_force_push?,
|
2019-07-07 11:18:12 +05:30
|
|
|
push_access_levels_attributes: AccessLevelParams.new(:push, params).access_levels,
|
|
|
|
merge_access_levels_attributes: AccessLevelParams.new(:merge, params).access_levels
|
2018-03-17 18:26:18 +05:30
|
|
|
}
|
|
|
|
end
|
2021-04-17 20:07:23 +05:30
|
|
|
|
|
|
|
def allow_force_push?
|
|
|
|
params[:allow_force_push] || false
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
|
|
|
ProtectedBranches::ApiService.prepend_if_ee('EE::ProtectedBranches::ApiService')
|