1# frozen_string_literal: true 2 3module ProtectedBranches 4 class UpdateService < ProtectedBranches::BaseService 5 def execute(protected_branch) 6 raise Gitlab::Access::AccessDeniedError unless can?(current_user, :update_protected_branch, protected_branch) 7 8 old_merge_access_levels = protected_branch.merge_access_levels.map(&:clone) 9 old_push_access_levels = protected_branch.push_access_levels.map(&:clone) 10 11 if protected_branch.update(filtered_params) 12 after_execute(protected_branch: protected_branch, old_merge_access_levels: old_merge_access_levels, old_push_access_levels: old_push_access_levels) 13 end 14 15 protected_branch 16 end 17 end 18end 19 20ProtectedBranches::UpdateService.prepend_mod_with('ProtectedBranches::UpdateService') 21