lib/gitlab_git/blob.rb in gitlab_git-10.6.3 vs lib/gitlab_git/blob.rb in gitlab_git-10.6.4

- old
+ new

@@ -11,11 +11,11 @@ # the user. We load as much as we can for encoding detection # (Linguist) and LFS pointer parsing. All other cases where we need full # blob data should use load_all_data!. MAX_DATA_DISPLAY_SIZE = 10485760 - attr_accessor :name, :path, :size, :data, :mode, :id, :commit_id, :loaded_size + attr_accessor :name, :path, :size, :data, :mode, :id, :commit_id, :loaded_size, :binary class << self def find(repository, sha, path) commit = repository.lookup(sha) root_tree = commit.tree @@ -36,10 +36,11 @@ size: blob.size, data: blob.content(MAX_DATA_DISPLAY_SIZE), mode: blob_entry[:filemode].to_s(8), path: path, commit_id: sha, + binary: blob.binary? ) end end end @@ -48,10 +49,11 @@ Blob.new( id: blob.oid, size: blob.size, data: blob.content(MAX_DATA_DISPLAY_SIZE), + binary: blob.binary? ) end # Recursive search of blob id by path # @@ -245,16 +247,20 @@ commit(repository, options, :rename) end end def initialize(options) - %w(id name path size data mode commit_id).each do |key| + %w(id name path size data mode commit_id binary).each do |key| self.send("#{key}=", options[key.to_sym]) end @loaded_all_data = false # Retain the actual size before it is encoded @loaded_size = @data.bytesize if @data + end + + def binary? + @binary.nil? ? super : @binary == true end def empty? !data || data == '' end