2019-08-09 09:40:45 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-02-19 18:09:10 +00:00
|
|
|
class UpdateExternalPullRequestsWorker # rubocop:disable Scalability/IdempotentWorker
|
2019-08-09 09:40:45 +00:00
|
|
|
include ApplicationWorker
|
|
|
|
|
2019-10-18 11:11:44 +00:00
|
|
|
feature_category :source_code_management
|
2020-01-24 18:09:00 +00:00
|
|
|
weight 3
|
2020-06-12 12:08:56 +00:00
|
|
|
loggable_arguments 2
|
2019-10-18 11:11:44 +00:00
|
|
|
|
2019-08-09 09:40:45 +00:00
|
|
|
def perform(project_id, user_id, ref)
|
|
|
|
project = Project.find_by_id(project_id)
|
|
|
|
return unless project
|
|
|
|
|
|
|
|
user = User.find_by_id(user_id)
|
|
|
|
return unless user
|
|
|
|
|
|
|
|
branch = Gitlab::Git.branch_name(ref)
|
|
|
|
return unless branch
|
|
|
|
|
|
|
|
external_pull_requests = project.external_pull_requests
|
|
|
|
.by_source_repository(project.import_source)
|
|
|
|
.by_source_branch(branch)
|
|
|
|
|
|
|
|
external_pull_requests.find_each do |pull_request|
|
2020-04-08 12:09:42 +00:00
|
|
|
Ci::ExternalPullRequests::CreatePipelineService.new(project, user)
|
2019-08-09 09:40:45 +00:00
|
|
|
.execute(pull_request)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|