2014-04-02 18:51:17 +00:00
|
|
|
module MergeRequests
|
|
|
|
class CloseService < MergeRequests::BaseService
|
|
|
|
def execute(merge_request, commit = nil)
|
2016-08-09 15:51:40 +00:00
|
|
|
return merge_request unless can?(current_user, :update_merge_request, merge_request)
|
|
|
|
|
2014-04-02 18:51:17 +00:00
|
|
|
# If we close MergeRequest we want to ignore validation
|
|
|
|
# so we can close broken one (Ex. fork project removed)
|
|
|
|
merge_request.allow_broken = true
|
|
|
|
|
|
|
|
if merge_request.close
|
|
|
|
event_service.close_mr(merge_request, current_user)
|
|
|
|
create_note(merge_request)
|
2015-01-26 06:49:05 +00:00
|
|
|
notification_service.close_mr(merge_request, current_user)
|
2016-02-20 13:59:59 +00:00
|
|
|
todo_service.close_merge_request(merge_request, current_user)
|
2015-01-18 00:34:34 +00:00
|
|
|
execute_hooks(merge_request, 'close')
|
2017-07-11 16:12:33 +00:00
|
|
|
invalidate_cache_counts(merge_request, users: merge_request.assignees)
|
2017-09-19 11:55:56 +00:00
|
|
|
merge_request.update_project_counter_caches
|
2014-04-02 18:51:17 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
merge_request
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|