Class: ProtectedBranches::LegacyApiCreateService

Inherits:
BaseService
  • Object
show all
Defined in:
app/services/protected_branches/legacy_api_create_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#executeObject


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/services/protected_branches/legacy_api_create_service.rb', line 9

def execute
  push_access_level =
    if params.delete(:developers_can_push)
      Gitlab::Access::DEVELOPER
    else
      Gitlab::Access::MAINTAINER
    end

  merge_access_level =
    if params.delete(:developers_can_merge)
      Gitlab::Access::DEVELOPER
    else
      Gitlab::Access::MAINTAINER
    end

  @params.merge!(push_access_levels_attributes: [{ access_level: push_access_level }],
                 merge_access_levels_attributes: [{ access_level: merge_access_level }])

  service = ProtectedBranches::CreateService.new(@project, @current_user, @params)
  service.execute
end