lib/gitlab_git/blob.rb in gitlab_git-7.0.0.rc10 vs lib/gitlab_git/blob.rb in gitlab_git-7.0.0.rc11

- old
+ new

@@ -13,22 +13,26 @@ blob_entry = find_entry_by_path(repository, root_tree.oid, path) return nil unless blob_entry - blob = repository.lookup(blob_entry[:oid]) + if blob_entry[:type] == :commit + submodule_blob(blob_entry, path, sha) + else + blob = repository.lookup(blob_entry[:oid]) - if blob - Blob.new( - id: blob.oid, - name: blob_entry[:name], - size: blob.size, - data: blob.content, - mode: blob_entry[:mode], - path: path, - commit_id: sha, - ) + if blob + Blob.new( + id: blob.oid, + name: blob_entry[:name], + size: blob.size, + data: blob.content, + mode: blob_entry[:mode], + path: path, + commit_id: sha, + ) + end end end def raw(repository, sha) blob = repository.lookup(sha) @@ -61,19 +65,24 @@ return nil unless entry if path_arr.size > 1 return nil unless entry[:type] == :tree - else - return nil unless entry[:type] == :blob - end - - if path_arr.size > 1 path_arr.shift find_entry_by_path(repository, entry[:oid], path_arr.join('/')) else - entry + [:blob, :commit].include?(entry[:type]) ? entry : nil end + end + + def submodule_blob(blob_entry, path, sha) + Blob.new( + id: blob_entry[:oid], + name: blob_entry[:name], + data: '', + path: path, + commit_id: sha, + ) end end def initialize(options) %w(id name path size data mode commit_id).each do |key|