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, Tree

Class Method Summary collapse

Class Method Details

.new(base, objectish, type = nil) ⇒ Git::Object::AbstractObject

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

Parameters:

  • base (Git::Repository) —

    the repository used to query object data

  • objectish (String) —

    the object name, SHA, ref, or treeish path

  • type (String, nil) (defaults to: nil) —

    object type hint: blob, commit, or tree

Returns:



532
533
534
535
536
537
538
539
540
541
# File 'lib/git/object.rb', line 532

def self.new(base, objectish, type = nil)
  type ||= object_repository_for(base).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