summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Duncalfe <lduncalfe@eml.cc>2019-03-20 12:07:51 +1300
committerLuke Duncalfe <lduncalfe@eml.cc>2019-03-22 10:26:16 +1300
commit23a462879f74f1bbc5c5e5642aadedad109c2c32 (patch)
treebbc2b2ff3bd66f31fbee7e9b62970132b9796903
parent33ca9d6515e1337858028006a32c3f6fa6717452 (diff)
downloadgitlab-ce-23a462879f74f1bbc5c5e5642aadedad109c2c32.tar.gz
Handle blank projects in CommitCollection#enrich!
A project is needed in order to fetch data from gitaly. Projects can be absent from commits in certain rare situations (like when viewing a MR of a deleted fork). In these cases, assume that the enriched data is not needed. See this comment: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/26144#note_152191106 "It's led to a dilemma about where to "fix" this in code. I'm going to fix it by allowing CommitCollection#enrich! to just return unenriched commits when a project is missing, essentially "silently failing". I hope this is the right decision. It's going with the assumption that calls in these situations in the future are not needing the full data. The alternative would be to allow CommitCollection#enrich! to still error, but handle it in the methods that call #enrich!, however that might lead to brittleness in future when working with project-less MRs."
-rw-r--r--app/models/commit_collection.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/commit_collection.rb b/app/models/commit_collection.rb
index f4e64abf362..52524456439 100644
--- a/app/models/commit_collection.rb
+++ b/app/models/commit_collection.rb
@@ -45,7 +45,11 @@ class CommitCollection
# Batch load any commits that are not backed by full gitaly data, and
# replace them in the collection.
def enrich!
- return self if fully_enriched?
+ # A project is needed in order to fetch data from gitaly. Projects
+ # can be absent from commits in certain rare situations (like when
+ # viewing a MR of a deleted fork). In these cases, assume that the
+ # enriched data is not needed.
+ return self if project.blank? || fully_enriched?
# Batch load full Commits from the repository
# and map to a Hash of id => Commit