Class: Avm::Git::Commit

Inherits:
Object
  • Object
show all
Defined in:
lib/avm/git/commit.rb,
lib/avm/git/commit/file.rb,
lib/avm/git/commit/class_methods.rb,
lib/avm/git/commit/diff_tree_line.rb

Defined Under Namespace

Modules: ClassMethods Classes: DiffTreeLine, File

Constant Summary collapse

FIELDS =
{
  author_name: '%an', author_email: '%ae', author_date: '%ai',
  subject: '%s',
  author_all: '%an <%ae>, %ai',
  commiter_name: '%cn', commiter_email: '%ce', commiter_date: '%ci',
  commiter_all: '%cn <%ce>, %ci'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(git, sha1) ⇒ Commit

Returns a new instance of Commit.

Parameters:

  • git (EacGit::Local)


22
23
24
25
# File 'lib/avm/git/commit.rb', line 22

def initialize(git, sha1)
  @git = git
  @sha1 = sha1
end

Instance Attribute Details

#gitObject (readonly)

Returns the value of attribute git.



19
20
21
# File 'lib/avm/git/commit.rb', line 19

def git
  @git
end

#sha1Object (readonly)

Returns the value of attribute sha1.



19
20
21
# File 'lib/avm/git/commit.rb', line 19

def sha1
  @sha1
end

Instance Method Details

#files_size_uncachedObject



41
42
43
# File 'lib/avm/git/commit.rb', line 41

def files_size_uncached
  files.inject(0) { |a, e| a + e.dst_size }
end

#files_uncachedObject



37
38
39
# File 'lib/avm/git/commit.rb', line 37

def files_uncached
  diff_tree_execute.each_line.map { |line| ::Avm::Git::Commit::File.new(git, line) }
end

#format(format) ⇒ Object



27
28
29
# File 'lib/avm/git/commit.rb', line 27

def format(format)
  git.command('--no-pager', 'log', '-1', "--pretty=format:#{format}", sha1).execute!.strip
end

#root_child?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/avm/git/commit.rb', line 45

def root_child?
  format('%P').blank?
end