debian-mirror-gitlab/app/services/merge_requests/close_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
1.5 KiB
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2014-09-02 18:07:02 +05:30
module MergeRequests
class CloseService < MergeRequests::BaseService
2020-11-24 15:15:51 +05:30
include RemovesRefs
2014-09-02 18:07:02 +05:30
def execute(merge_request, commit = nil)
2016-09-13 17:45:13 +05:30
return merge_request unless can?(current_user, :update_merge_request, merge_request)
2014-09-02 18:07:02 +05:30
# 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
2018-03-17 18:26:18 +05:30
create_event(merge_request)
2021-03-08 18:12:59 +05:30
merge_request_activity_counter.track_close_mr_action(user: current_user)
2014-09-02 18:07:02 +05:30
create_note(merge_request)
2018-10-15 14:42:47 +05:30
notification_service.async.close_mr(merge_request, current_user)
2016-04-02 18:10:28 +05:30
todo_service.close_merge_request(merge_request, current_user)
2022-01-26 12:08:38 +05:30
remove_all_attention_requests(merge_request)
2015-04-26 12:48:37 +05:30
execute_hooks(merge_request, 'close')
2021-03-08 18:12:59 +05:30
invalidate_cache_counts(merge_request, users: merge_request.assignees | merge_request.reviewers)
2018-03-17 18:26:18 +05:30
merge_request.update_project_counter_caches
2019-07-07 11:18:12 +05:30
cleanup_environments(merge_request)
2019-09-30 21:07:59 +05:30
abort_auto_merge(merge_request, 'merge request was closed')
2020-11-24 15:15:51 +05:30
cleanup_refs(merge_request)
2014-09-02 18:07:02 +05:30
end
merge_request
end
2018-03-17 18:26:18 +05:30
private
def create_event(merge_request)
# Making sure MergeRequest::Metrics updates are in sync with
# Event creation.
Event.transaction do
close_event = event_service.close_mr(merge_request, current_user)
merge_request_metrics_service(merge_request).close(close_event)
end
end
2014-09-02 18:07:02 +05:30
end
end