2020-03-06 16:07:59 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module MergeRequests
|
|
|
|
class AfterCreateService < MergeRequests::BaseService
|
|
|
|
def execute(merge_request)
|
2021-03-09 13:09:41 -05:00
|
|
|
prepare_merge_request(merge_request)
|
|
|
|
merge_request.mark_as_unchecked if merge_request.preparing?
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def prepare_merge_request(merge_request)
|
2020-03-06 16:07:59 -05:00
|
|
|
event_service.open_mr(merge_request, current_user)
|
2021-03-05 10:09:12 -05:00
|
|
|
|
2021-01-07 13:10:38 -05:00
|
|
|
merge_request_activity_counter.track_create_mr_action(user: current_user)
|
2021-03-05 10:09:12 -05:00
|
|
|
merge_request_activity_counter.track_mr_including_ci_config(user: current_user, merge_request: merge_request)
|
|
|
|
|
2020-03-06 16:07:59 -05:00
|
|
|
notification_service.new_merge_request(merge_request, current_user)
|
|
|
|
|
2020-03-27 08:07:43 -04:00
|
|
|
create_pipeline_for(merge_request, current_user)
|
|
|
|
merge_request.update_head_pipeline
|
2020-03-06 16:07:59 -05:00
|
|
|
|
|
|
|
merge_request.diffs(include_stats: false).write_cache
|
|
|
|
merge_request.create_cross_references!(current_user)
|
2020-12-07 10:09:49 -05:00
|
|
|
|
2021-01-11 07:10:41 -05:00
|
|
|
OnboardingProgressService.new(merge_request.target_project.namespace).execute(action: :merge_request_created)
|
2021-04-01 05:09:05 -04:00
|
|
|
|
|
|
|
todo_service.new_merge_request(merge_request, current_user)
|
|
|
|
merge_request.cache_merge_request_closes_issues!(current_user)
|
|
|
|
|
|
|
|
Gitlab::UsageDataCounters::MergeRequestCounter.count(:create)
|
|
|
|
link_lfs_objects(merge_request)
|
2021-04-08 14:09:32 -04:00
|
|
|
|
|
|
|
delete_milestone_total_merge_requests_counter_cache(merge_request.milestone)
|
2021-04-01 05:09:05 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def link_lfs_objects(merge_request)
|
2021-05-11 23:10:21 -04:00
|
|
|
LinkLfsObjectsService.new(project: merge_request.target_project).execute(merge_request)
|
2020-03-06 16:07:59 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-08-19 17:10:32 -04:00
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
MergeRequests::AfterCreateService.prepend_mod_with('MergeRequests::AfterCreateService')
|