summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/merge_request.rb18
1 files changed, 11 insertions, 7 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 4673f895a1a..4cd402b1354 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -747,17 +747,21 @@ class MergeRequest < ActiveRecord::Base
def all_pipelines
return unless source_project
- @all_pipelines ||= source_project.pipelines.order(id: :desc).
- where(sha: all_commits_sha, ref: source_branch)
+ @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
- if persisted?
- merge_request_diffs.flat_map(&:commits_sha).uniq
- else
- [diff_head_sha]
- end
+ merge_request_diffs.flat_map(&:commits_sha).uniq
end
def merge_commit