diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-09-20 17:36:21 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-09-20 17:36:21 +0800 |
commit | 307be4b52145d271cfddfbbd91b8bd2280ce31ae (patch) | |
tree | 5f60c71f6e754f465feb6035be89e79a21fe442c | |
parent | 54483462018a27506d826a96b3f7ee3166fb6c7e (diff) | |
download | gitlab-ce-307be4b52145d271cfddfbbd91b8bd2280ce31ae.tar.gz |
Introduce MergeRequest#all_commits_sha, feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6414#note_15746083
-rw-r--r-- | app/models/merge_request.rb | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 4532e7df7b5..5af01846699 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -747,15 +747,16 @@ class MergeRequest < ActiveRecord::Base def all_pipelines return unless source_project - @all_pipelines ||= begin - if persisted? - sha = merge_request_diffs.flat_map(&:commits_sha).uniq - else - sha = diff_head_sha - end + @all_pipelines ||= source_project.pipelines.order(id: :desc). + where(sha: all_commits_sha, ref: source_branch) + end - source_project.pipelines.order(id: :desc). - where(sha: sha, ref: source_branch) + # Note that this would also return SHA from dangling commits + def all_commits_sha + if persisted? + merge_request_diffs.flat_map(&:commits_sha).uniq + else + [diff_head_sha] end end |