diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-06 21:07:59 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-06 21:07:59 +0000 |
commit | 1c25ac983cd1e4335faa1ec4922c314d6321e224 (patch) | |
tree | 68d88ab5d9ed5c3397e52fe85fc38ab237335a91 /app/services | |
parent | 83731155d997ae24c7e0cd5ffa6f0dba41bec6dc (diff) | |
download | gitlab-ce-1c25ac983cd1e4335faa1ec4922c314d6321e224.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/merge_requests/after_create_service.rb | 19 | ||||
-rw-r--r-- | app/services/merge_requests/create_service.rb | 21 |
2 files changed, 30 insertions, 10 deletions
diff --git a/app/services/merge_requests/after_create_service.rb b/app/services/merge_requests/after_create_service.rb new file mode 100644 index 00000000000..6da30f8af16 --- /dev/null +++ b/app/services/merge_requests/after_create_service.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module MergeRequests + class AfterCreateService < MergeRequests::BaseService + def execute(merge_request) + event_service.open_mr(merge_request, current_user) + notification_service.new_merge_request(merge_request, current_user) + + # https://gitlab.com/gitlab-org/gitlab/issues/208813 + if ::Feature.enabled?(:create_merge_request_pipelines_in_sidekiq, project) + create_pipeline_for(merge_request, current_user) + merge_request.update_head_pipeline + end + + merge_request.diffs(include_stats: false).write_cache + merge_request.create_cross_references!(current_user) + end + end +end diff --git a/app/services/merge_requests/create_service.rb b/app/services/merge_requests/create_service.rb index 4a05d1fd7ef..d957a6425b2 100644 --- a/app/services/merge_requests/create_service.rb +++ b/app/services/merge_requests/create_service.rb @@ -13,19 +13,20 @@ module MergeRequests create(merge_request) end - def before_create(merge_request) - # current_user (defined in BaseService) is not available within run_after_commit block - user = current_user - merge_request.run_after_commit do - NewMergeRequestWorker.perform_async(merge_request.id, user.id) - end - end - def after_create(issuable) + # Add new items to MergeRequests::AfterCreateService if they can + # be performed in Sidekiq + NewMergeRequestWorker.perform_async(issuable.id, current_user.id) + todo_service.new_merge_request(issuable, current_user) issuable.cache_merge_request_closes_issues!(current_user) - create_pipeline_for(issuable, current_user) - issuable.update_head_pipeline + + # https://gitlab.com/gitlab-org/gitlab/issues/208813 + unless ::Feature.enabled?(:create_merge_request_pipelines_in_sidekiq, project) + create_pipeline_for(issuable, current_user) + issuable.update_head_pipeline + end + Gitlab::UsageDataCounters::MergeRequestCounter.count(:create) link_lfs_objects(issuable) |