diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-04 15:08:40 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-04 15:08:40 +0000 |
commit | 6b833f1e0340e00fdee074da9c42c0d4e07a46d2 (patch) | |
tree | 6fc3a7a2f8a02fec8d1e7561b453d33eb4048dad /app/models/blob.rb | |
parent | 88a0824944720b6edaaef56376713541b9a02118 (diff) | |
download | gitlab-ce-6b833f1e0340e00fdee074da9c42c0d4e07a46d2.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/blob.rb')
-rw-r--r-- | app/models/blob.rb | 19 |
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 |