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:
authorStan Hu <stanhu@gmail.com>2018-07-09 16:29:46 +0300
committerStan Hu <stanhu@gmail.com>2018-07-09 16:30:19 +0300
commit31f2608161945d3c1189509955d68209934e2988 (patch)
tree33b91a667cae2ead7f35efc7a92370091e2b8538 /lib/extracts_path.rb
parent0ed8f3490e037d451841ec0e6fe226b9e62e8466 (diff)
Fix handling of annotated tags when Gitaly is not in use
Attempting to view an annotated tag in the TreeController would result in `NoMethodError: undefined method 'tree'` when Rugged was in use. `Blob#find_by_rugged` assumes that the ref is a true. Using the commit ID ensures that the right ref is being used. Note that in 11.1, `Blob#find` no longer uses Rugged, so this is only a bug in 11.0. Closes gitlab-org/gitlab-ce#47797
Diffstat (limited to 'lib/extracts_path.rb')
-rw-r--r--lib/extracts_path.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb
index a9b04c183ad..e8dbde176ef 100644
--- a/lib/extracts_path.rb
+++ b/lib/extracts_path.rb
@@ -139,6 +139,11 @@ module ExtractsPath
def lfs_blob_ids
blob_ids = tree.blobs.map(&:id)
+
+ # When current endpoint is a Blob then `tree.blobs` will be empty, it means we need to analyze
+ # the current Blob in order to determine if it's a LFS object
+ blob_ids = Array.wrap(@repo.blob_at(@commit.id, @path)&.id) if blob_ids.empty? # rubocop:disable Gitlab/ModuleWithInstanceVariables
+
@lfs_blob_ids = Gitlab::Git::Blob.batch_lfs_pointers(@project.repository, blob_ids).map(&:id) # rubocop:disable Gitlab/ModuleWithInstanceVariables
end