Sha256: 39f97888b3de3ed41ee0cfddb7c95ad693ff5d2b783b7faae3ca2140c2efc0a6

Contents?: true

Size: 891 Bytes

Versions: 8

Compression:

Stored size: 891 Bytes

Contents

module Gitlab
  module Git
    class Blob
      include Linguist::BlobHelper

      attr_accessor :name, :path, :size, :data, :mode, :id, :commit_id

      class << self
        def find(repository, sha, path)
          commit = Commit.find(repository, sha)
          grit_blob = commit.tree / path

          if grit_blob.kind_of?(Grit::Blob)
            Blob.new(
              id: grit_blob.id,
              name: grit_blob.name,
              size: grit_blob.size,
              data: grit_blob.data,
              mode: grit_blob.mode,
              path: path,
              commit_id: sha,
            )
          end
        end
      end

      def initialize(options)
        %w(id name path size data mode commit_id).each do |key|
          self.send("#{key}=", options[key.to_sym])
        end
      end

      def empty?
        !data || data == ''
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
gitlab_git-4.0.0.pre lib/gitlab_git/blob.rb
gitlab_git-3.1.0 lib/gitlab_git/blob.rb
gitlab_git-3.0.1 lib/gitlab_git/blob.rb
gitlab_git-3.0.0 lib/gitlab_git/blob.rb
gitlab_git-3.0.0.rc2 lib/gitlab_git/blob.rb
gitlab_git-3.0.0.rc1 lib/gitlab_git/blob.rb
gitlab_git-3.0.0.beta1 lib/gitlab_git/blob.rb
gitlab_git-3.0.0.pre lib/gitlab_git/blob.rb