Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-03 03:05:59 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-03 03:05:59 +0300
commit427b23c12718bea233931431e7d9307881a960c0 (patch)
tree5e15672783c950a5e68dd89517d7888e652e01a7 /app/models/commit_collection.rb
parent6d60f910762c1a92a07a4afaf1b26962f75ee4b6 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/commit_collection.rb')
-rw-r--r--app/models/commit_collection.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/app/models/commit_collection.rb b/app/models/commit_collection.rb
index 6b303c52283..d4c29aa295b 100644
--- a/app/models/commit_collection.rb
+++ b/app/models/commit_collection.rb
@@ -72,8 +72,15 @@ class CommitCollection
end.compact]
# Replace the commits, keeping the same order
- @commits = @commits.map do |c|
- replacements.fetch(c.id, c)
+ @commits = @commits.map do |original_commit|
+ # Return the original instance: if it didn't need to be batchloaded, it was
+ # already enriched.
+ batch_loaded_commit = replacements.fetch(original_commit.id, original_commit)
+
+ # If batch loading the commit failed, fall back to the original commit.
+ # We need to explicitly check `.nil?` since otherwise a `BatchLoader` instance
+ # that looks like `nil` is returned.
+ batch_loaded_commit.nil? ? original_commit : batch_loaded_commit
end
self