diff options
author | Shinya Maeda <shinya@gitlab.com> | 2019-03-27 15:46:29 +0700 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2019-05-06 13:20:47 +0700 |
commit | d4d2cf7327ed077e063d64dcfe3b8275286c2d06 (patch) | |
tree | e34dd4a38e8dd37670f6922e1b884634132c89b9 /app | |
parent | 9aa81c0a95b0e54bbafca4755e95f27ee1eeb759 (diff) | |
download | gitlab-ce-d4d2cf7327ed077e063d64dcfe3b8275286c2d06.tar.gz |
Fix merge request pipeline exist methodfix-merge-request-pipeline-exist-method
Refactor
Diffstat (limited to 'app')
-rw-r--r-- | app/models/merge_request.rb | 10 | ||||
-rw-r--r-- | app/services/merge_requests/base_service.rb | 2 |
2 files changed, 4 insertions, 8 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index c2a1487fc6e..df162e4844c 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -66,7 +66,7 @@ class MergeRequest < ApplicationRecord dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent has_many :cached_closes_issues, through: :merge_requests_closing_issues, source: :issue - has_many :merge_request_pipelines, foreign_key: 'merge_request_id', class_name: 'Ci::Pipeline' + has_many :pipelines_for_merge_request, foreign_key: 'merge_request_id', class_name: 'Ci::Pipeline' has_many :suggestions, through: :notes has_many :merge_request_assignees @@ -1157,10 +1157,6 @@ class MergeRequest < ApplicationRecord end end - def merge_request_pipeline_exists? - merge_request_pipelines.exists?(sha: diff_head_sha) - end - def has_test_reports? actual_head_pipeline&.has_reports?(Ci::JobArtifact.test_reports) end @@ -1379,12 +1375,12 @@ class MergeRequest < ApplicationRecord source_project.repository.squash_in_progress?(id) end - private - def find_actual_head_pipeline all_pipelines.for_sha_or_source_sha(diff_head_sha).first end + private + def source_project_variables Gitlab::Ci::Variables::Collection.new.tap do |variables| break variables unless source_project diff --git a/app/services/merge_requests/base_service.rb b/app/services/merge_requests/base_service.rb index a9dd26c02ad..bb9062e9b40 100644 --- a/app/services/merge_requests/base_service.rb +++ b/app/services/merge_requests/base_service.rb @@ -81,7 +81,7 @@ module MergeRequests ## # UpdateMergeRequestsWorker could be retried by an exception. # pipelines for merge request should not be recreated in such case. - return false if merge_request.merge_request_pipeline_exists? + return false if merge_request.find_actual_head_pipeline&.triggered_by_merge_request? return false if merge_request.has_no_commits? true |