summaryrefslogtreecommitdiff
path: root/app/services/merge_requests/create_service.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-06-01 13:31:52 -0500
committerDouwe Maan <douwe@selenight.nl>2017-06-01 13:31:52 -0500
commit94be44c568b0167bbcc1e975ab674747a8271dbc (patch)
treec5130a2d2780eb155190f84abf4e8e48fe3e0b6f /app/services/merge_requests/create_service.rb
parent42c13b26dab4f52e90bc8be2b6f46d2ef9559ccd (diff)
downloadgitlab-ce-94be44c568b0167bbcc1e975ab674747a8271dbc.tar.gz
Fix race condition between pipeline creation and MR diff_head_sha update
Diffstat (limited to 'app/services/merge_requests/create_service.rb')
-rw-r--r--app/services/merge_requests/create_service.rb9
1 files changed, 3 insertions, 6 deletions
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