diff options
Diffstat (limited to 'app/services/protected_branches/api_create_service.rb')
-rw-r--r-- | app/services/protected_branches/api_create_service.rb | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/app/services/protected_branches/api_create_service.rb b/app/services/protected_branches/api_create_service.rb index a28056035b8..cbb99ede9f3 100644 --- a/app/services/protected_branches/api_create_service.rb +++ b/app/services/protected_branches/api_create_service.rb @@ -11,17 +11,22 @@ module ProtectedBranches end def execute - if @developers_can_push - @params.merge!(push_access_levels_attributes: [{ access_level: Gitlab::Access::DEVELOPER }]) - else - @params.merge!(push_access_levels_attributes: [{ access_level: Gitlab::Access::MASTER }]) - end + push_access_level = + if @developers_can_push + Gitlab::Access::DEVELOPER + else + Gitlab::Access::MASTER + end - if @developers_can_merge - @params.merge!(merge_access_levels_attributes: [{ access_level: Gitlab::Access::DEVELOPER }]) - else - @params.merge!(merge_access_levels_attributes: [{ access_level: Gitlab::Access::MASTER }]) - end + merge_access_level = + if @developers_can_merge + Gitlab::Access::DEVELOPER + else + Gitlab::Access::MASTER + 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 |