summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-09-20 20:29:07 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-09-20 20:29:07 +0800
commit3ae99b2c9fd82e7be0f8b404167e656102aa6c8b (patch)
tree29656b7b7ee451dd7337bc8e3112fad4bc9aae3e
parent55de6e15d3b29c89a137e3e8824f02ddc4b7c1e7 (diff)
downloadgitlab-ce-3ae99b2c9fd82e7be0f8b404167e656102aa6c8b.tar.gz
If merge request wasn't persisted yet, we show only 1 pipeline:
However, if MergeRequest#all_commits_sha would want to handle non-persisted merge request, by judging its name, it should not just give 1 SHA, but all of them. But we don't really care all_commits_sha for non-persisted merge request anyway. So I think we should just ignore that case. Better to not implementing something than implementing it in a wrong and confusing way.
-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