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:
Diffstat (limited to 'app/models/blob.rb')
-rw-r--r--app/models/blob.rb19
1 files changed, 11 insertions, 8 deletions
diff --git a/app/models/blob.rb b/app/models/blob.rb
index 258006d8d2e..d8282c918b7 100644
--- a/app/models/blob.rb
+++ b/app/models/blob.rb
@@ -65,7 +65,10 @@ class Blob < SimpleDelegator
BlobViewer::YarnLock
].freeze
- attr_reader :project
+ attr_reader :container
+
+ delegate :repository, to: :container, allow_nil: true
+ delegate :project, to: :repository, allow_nil: true
# Wrap a Gitlab::Git::Blob object, or return nil when given nil
#
@@ -77,22 +80,22 @@ class Blob < SimpleDelegator
#
# blob = Blob.decorate(nil)
# puts "truthy" if blob # No output
- def self.decorate(blob, project = nil)
+ def self.decorate(blob, container = nil)
return if blob.nil?
- new(blob, project)
+ new(blob, container)
end
- def self.lazy(project, commit_id, path, blob_size_limit: Gitlab::Git::Blob::MAX_DATA_DISPLAY_SIZE)
- BatchLoader.for([commit_id, path]).batch(key: project.repository) do |items, loader, args|
+ def self.lazy(container, commit_id, path, blob_size_limit: Gitlab::Git::Blob::MAX_DATA_DISPLAY_SIZE)
+ BatchLoader.for([commit_id, path]).batch(key: container.repository) do |items, loader, args|
args[:key].blobs_at(items, blob_size_limit: blob_size_limit).each do |blob|
loader.call([blob.commit_id, blob.path], blob) if blob
end
end
end
- def initialize(blob, project = nil)
- @project = project
+ def initialize(blob, container = nil)
+ @container = container
super(blob)
end
@@ -116,7 +119,7 @@ class Blob < SimpleDelegator
def load_all_data!
# Endpoint needed: https://gitlab.com/gitlab-org/gitaly/issues/756
Gitlab::GitalyClient.allow_n_plus_1_calls do
- super(project.repository) if project
+ super(repository) if container
end
end