From e0f596c99debe880dfcaed66220a9483d0c81e7b Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Mon, 19 Sep 2016 23:51:27 +0800 Subject: Show all pipelines from all merge_request_diffs: This way we could also show pipelines from commits which were discarded due to a force push. --- app/models/merge_request.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'app/models/merge_request.rb') diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 75f48fd4ba5..4532e7df7b5 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -745,10 +745,18 @@ class MergeRequest < ActiveRecord::Base end def all_pipelines - @all_pipelines ||= - if diff_head_sha && source_project - source_project.pipelines.order(id: :desc).where(sha: commits_sha, ref: source_branch) + return unless source_project + + @all_pipelines ||= begin + if persisted? + sha = merge_request_diffs.flat_map(&:commits_sha).uniq + else + sha = diff_head_sha end + + source_project.pipelines.order(id: :desc). + where(sha: sha, ref: source_branch) + end end def merge_commit -- cgit v1.2.1