diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-03 03:05:59 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-03 03:05:59 +0300 |
commit | 427b23c12718bea233931431e7d9307881a960c0 (patch) | |
tree | 5e15672783c950a5e68dd89517d7888e652e01a7 /app/models/commit_collection.rb | |
parent | 6d60f910762c1a92a07a4afaf1b26962f75ee4b6 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/commit_collection.rb')
-rw-r--r-- | app/models/commit_collection.rb | 11 |
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 |