Class: EacGit::Local::Commit

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/eac_git/local/commit.rb,
lib/eac_git/local/commit/archive.rb,
lib/eac_git/local/commit/changed_file.rb,
lib/eac_git/local/commit/diff_tree_line.rb

Defined Under Namespace

Modules: Archive Classes: ChangedFile, DiffTreeLine

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#<=>(other) ⇒ Object



24
25
26
# File 'lib/eac_git/local/commit.rb', line 24

def <=>(other)
  [repo, id] <=> [other.repo, other.id]
end

#changed_files_size_uncachedObject



42
43
44
# File 'lib/eac_git/local/commit.rb', line 42

def changed_files_size_uncached
  changed_files.inject(0) { |a, e| a + e.dst_size }
end

#changed_files_uncachedObject



36
37
38
39
40
# File 'lib/eac_git/local/commit.rb', line 36

def changed_files_uncached
  diff_tree_execute.each_line.map do |line|
    ::EacGit::Local::Commit::ChangedFile.new(self, line)
  end
end

#format(format) ⇒ Object



28
29
30
# File 'lib/eac_git/local/commit.rb', line 28

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

#parentEacGit::Local::Commit?

Returns:



47
48
49
50
51
52
# File 'lib/eac_git/local/commit.rb', line 47

def parent
  ps = parents
  raise "#{self} has more than one parent" if ps.count > 2

  ps.empty? ? nil : ps.first
end

#parentsArray<EacGit::Local::Commit>

Returns:



55
56
57
# File 'lib/eac_git/local/commit.rb', line 55

def parents
  format('%P').each_line.map { |line| repo.commitize(line) }
end

#root_child?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/eac_git/local/commit.rb', line 59

def root_child?
  parents.empty?
end