2018-07-18 12:03:33 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-24 07:05:04 -04:00
|
|
|
module ProtectedBranches
|
2021-09-07 11:11:06 -04:00
|
|
|
class DestroyService < ProtectedBranches::BaseService
|
2018-03-24 07:05:04 -04:00
|
|
|
def execute(protected_branch)
|
2018-03-24 20:54:56 -04:00
|
|
|
raise Gitlab::Access::AccessDeniedError unless can?(current_user, :destroy_protected_branch, protected_branch)
|
|
|
|
|
2022-07-29 11:12:25 -04:00
|
|
|
protected_branch.destroy.tap { refresh_cache }
|
2018-03-24 07:05:04 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-09-17 08:06:48 -04:00
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
ProtectedBranches::DestroyService.prepend_mod_with('ProtectedBranches::DestroyService')
|