BigW Consortium Gitlab

Commit 3ae99b2c by Lin Jen-Shin

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.
parent 55de6e15
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment