diff options
author | Felipe Artur <felipefac@gmail.com> | 2017-05-24 00:36:57 +0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2017-05-24 00:58:02 +0300 |
commit | 5b9e801e819b6daf1804874ed962bc2f1650c8da (patch) | |
tree | dd35d78ef4c0a04e346c7c0a9e1e7806899f1ddc /app/services/ci/create_pipeline_service.rb | |
parent | 52527be4387cb978402a330f2e4de96e586a62db (diff) |
Sanity check pipeline sha before saving merge request head pipeline
Diffstat (limited to 'app/services/ci/create_pipeline_service.rb')
-rw-r--r-- | app/services/ci/create_pipeline_service.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/app/services/ci/create_pipeline_service.rb b/app/services/ci/create_pipeline_service.rb index 1f6c1f4a7f6..801ff410fb5 100644 --- a/app/services/ci/create_pipeline_service.rb +++ b/app/services/ci/create_pipeline_service.rb @@ -119,8 +119,14 @@ module Ci end def update_merge_requests_head_pipeline - MergeRequest.where(source_branch: @pipeline.ref, source_project: @pipeline.project). - update_all(head_pipeline_id: @pipeline.id) + merge_requests = MergeRequest.where(source_branch: @pipeline.ref, source_project: @pipeline.project) + + merge_requests_ids = + merge_requests.select do |mr| + mr.diff_head_sha == @pipeline.sha + end.map(&:id) + + MergeRequest.where(id: merge_requests_ids).update_all(head_pipeline_id: @pipeline.id) end def error(message, save: false) |