diff options
author | Rémy Coutable <remy@rymai.me> | 2016-09-21 16:15:41 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-09-21 16:15:41 +0300 |
commit | 529b17d11c215f813af3f9a2b80db83a157bf247 (patch) | |
tree | 69e7dc50a0e94f6f359f5f255ef2e55772c211ac /app | |
parent | 786367032556711b9ad80e83c1973cd557962df2 (diff) | |
parent | 93ab5856e4de9a13e730cf9d200e4f0934f4bece (diff) |
Merge branch 'show-all-pipelines-from-all-diffs' into 'master'
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.
Closes #21889
See merge request !6414
Diffstat (limited to 'app')
-rw-r--r-- | app/models/merge_request.rb | 21 | ||||
-rw-r--r-- | app/models/merge_request_diff.rb | 8 |
2 files changed, 25 insertions, 4 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 4c51c979599..2dcf7f89bfc 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -764,10 +764,23 @@ 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) - end + return unless source_project + + @all_pipelines ||= begin + sha = if persisted? + all_commits_sha + else + diff_head_sha + end + + source_project.pipelines.order(id: :desc). + where(sha: sha, ref: source_branch) + end + end + + # Note that this could also return SHA from now dangling commits + def all_commits_sha + merge_request_diffs.flat_map(&:commits_sha).uniq end def merge_commit diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb index 18c583add88..7362886e9f5 100644 --- a/app/models/merge_request_diff.rb +++ b/app/models/merge_request_diff.rb @@ -117,6 +117,14 @@ class MergeRequestDiff < ActiveRecord::Base project.commit(head_commit_sha) end + def commits_sha + if @commits + commits.map(&:sha) + else + st_commits.map { |commit| commit[:id] } + end + end + def diff_refs return unless start_commit_sha || base_commit_sha |