Class: Git::Object

Inherits:
Object
  • Object
show all
Defined in:
lib/git/object.rb

Overview

represents a git object

Defined Under Namespace

Classes: AbstractObject, Blob, Commit, Tag, Tree

Class Method Summary collapse

Class Method Details

.new(base, objectish, type = nil, is_tag = false)

if we're calling this, we don't know what type it is yet so this is our little factory method



294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
# File 'lib/git/object.rb', line 294

def self.new(base, objectish, type = nil, is_tag = false)
  if is_tag
    sha = base.lib.tag_sha(objectish)
    if sha == ''
      raise Git::UnexpectedResultError.new("Tag '#{objectish}' does not exist.")
    end
    return Git::Object::Tag.new(base, sha, objectish)
  end

  type ||= base.lib.cat_file_type(objectish)
  klass =
    case type
    when /blob/   then Blob
    when /commit/ then Commit
    when /tree/   then Tree
    end
  klass.new(base, objectish)
end