diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/services/ci/create_pipeline_service.rb | 9 | ||||
-rw-r--r-- | app/services/merge_requests/create_service.rb | 9 |
2 files changed, 6 insertions, 12 deletions
diff --git a/app/services/ci/create_pipeline_service.rb b/app/services/ci/create_pipeline_service.rb index 8227a78a650..13baa63220d 100644 --- a/app/services/ci/create_pipeline_service.rb +++ b/app/services/ci/create_pipeline_service.rb @@ -63,13 +63,10 @@ module Ci private def update_merge_requests_head_pipeline - merge_requests = MergeRequest.where(source_branch: @pipeline.ref, source_project: @pipeline.project) + return unless pipeline.latest? - merge_requests = merge_requests.select do |mr| - mr.diff_head_sha == @pipeline.sha - end - - MergeRequest.where(id: merge_requests).update_all(head_pipeline_id: @pipeline.id) + MergeRequest.where(source_project: @pipeline.project, source_branch: @pipeline.ref). + update_all(head_pipeline_id: @pipeline.id) end def skip_ci? diff --git a/app/services/merge_requests/create_service.rb b/app/services/merge_requests/create_service.rb index fbf171f705e..71d37797bb4 100644 --- a/app/services/merge_requests/create_service.rb +++ b/app/services/merge_requests/create_service.rb @@ -30,15 +30,12 @@ module MergeRequests def head_pipeline_for(merge_request) return unless merge_request.source_project - sha = merge_request.source_branch_head&.id - + sha = merge_request.source_branch_sha return unless sha - pipelines = - Ci::Pipeline.where(ref: merge_request.source_branch, project_id: merge_request.source_project.id, sha: sha). - order(id: :desc) + pipelines = merge_request.source_project.pipelines.where(ref: merge_request.source_branch, sha: sha) - pipelines.first + pipelines.order(id: :desc).first end end end |