Class: V::Adapters::Git::Commit

Inherits:
ObjectType show all
Defined in:
lib/v/adapters/git/object_types/commit.rb

Constant Summary collapse

F =

see ‘git help show` for details

{
  :commit_hash          => '%H',
  :commit_hash_abbrev   => '%h',
  :tree_hash            => '%T', #
  :tree_hash_abbrev     => '%t',
  :parent_hashes        => '%P', #
  :parent_hashes_abbrev => '%p',
  :a_name               => '%an', #
  :a_name_mailmap       => '%aN',
  :a_email              => '%ae', #
  :a_email_mailmap      => '%aE',
  :a_date               => '%ad',
  :a_date_rfc2822       => '%aD',
  :a_date_relative      => '%ar',
  :a_date_unix          => '%at', #
  :a_date_iso8601       => '%ai',
  :c_name               => '%cn', #
  :c_name_mailmap       => '%cN',
  :c_email              => '%ce', #
  :c_email_mailmap      => '%cE',
  :c_date               => '%cd',
  :c_date_rfc2822       => '%cD',
  :c_date_relative      => '%cr',
  :c_date_unix          => '%ct', #
  :c_date_iso8601       => '%ci',
  :ref_names            => '%d',
  :encoding             => '%e',
  :subject              => '%s', #
  :subject_sanitized    => '%f',
  :body                 => '%b', # extra
  :red                  => '%Cred',
  :green                => '%Cgreen',
  :blue                 => '%Cblue',
  :reset_color          => '%Creset',
  :newline              => '%n',
  :hex                  => '%%x%02x'
#                     o    %m: left, right or boundary mark
#                     o    %C(...): color specification, as described in color.branch.* config option
}
FORMAT =

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ObjectType

#===, ===, #to_s

Class Method Details

.with(environment, attrs = {}) ⇒ Object

Completes :name in attrs and returns a Git::Object with type :commit.



8
9
10
11
12
13
14
15
16
17
# File 'lib/v/adapters/git/object_types/commit.rb', line 8

def self.with(environment, attrs = {})
  if attrs[:name].length < 40
    glob = File.join environment.git_dir, 'objects',
        attrs[:name][0, 2], "#{ attrs[:name][2, 38] }*"

    attrs[:name] = attrs[:name][0, 2] + File.basename(Dir[ glob ].first)
  end

  Object.new environment, attrs.update(:type => :commit)
end

Instance Method Details

#author(object) ⇒ Object



77
78
79
# File 'lib/v/adapters/git/object_types/commit.rb', line 77

def author(object)
  fetch object, :author
end

#body(object) ⇒ Object



86
87
88
# File 'lib/v/adapters/git/object_types/commit.rb', line 86

def body(object)
  fetch object, :body
end

#committer(object) ⇒ Object



80
81
82
# File 'lib/v/adapters/git/object_types/commit.rb', line 80

def committer(object)
  fetch object, :commiter
end

#content(object) ⇒ Object



67
68
69
# File 'lib/v/adapters/git/object_types/commit.rb', line 67

def content(object)
  object.environment.show object.name, :pretty => FORMAT
end

#parents(object) ⇒ Object



74
75
76
# File 'lib/v/adapters/git/object_types/commit.rb', line 74

def parents(object)
  fetch object, :parents
end

#path(parent, *basenames) ⇒ Object



90
91
92
# File 'lib/v/adapters/git/object_types/commit.rb', line 90

def path(parent, *basenames)
  basenames.compact * '/'
end

#subject(object) ⇒ Object



83
84
85
# File 'lib/v/adapters/git/object_types/commit.rb', line 83

def subject(object)
  fetch object, :subject
end

#tree(object) ⇒ Object



71
72
73
# File 'lib/v/adapters/git/object_types/commit.rb', line 71

def tree(object)
  fetch object, :tree
end