Class: Branches::DeleteMergedService
- Inherits:
-
BaseService
- Object
- BaseService
- Branches::DeleteMergedService
- Defined in:
- app/services/branches/delete_merged_service.rb
Instance Attribute Summary
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
Methods inherited from BaseService
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
Constructor Details
This class inherits a constructor from BaseService
Instance Method Details
#async_execute ⇒ Object
5 6 7 |
# File 'app/services/branches/delete_merged_service.rb', line 5 def async_execute DeleteMergedBranchesWorker.perform_async(project.id, current_user.id) end |
#execute ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/services/branches/delete_merged_service.rb', line 9 def execute raise Gitlab::Access::AccessDeniedError unless can?(current_user, :push_code, project) branches = project.repository.merged_branch_names # Prevent deletion of branches relevant to open merge requests branches -= merge_request_branch_names # Prevent deletion of protected branches branches = branches.reject { |branch| ProtectedBranch.protected?(project, branch) } branches.each do |branch| ::Branches::DeleteService.new(project, current_user).execute(branch) end end |