Class: GitSniffer::Commit
Instance Attribute Summary
Attributes inherited from Object
#sha
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Object
create_object, #eql?, #hash, #lazy_content_source, #lazy_type_source, object_type
Methods included from Lazy
included
Methods included from Hook
included
Constructor Details
#initialize(base, sha) ⇒ Commit
Returns a new instance of Commit.
11
12
13
|
# File 'lib/git_sniffer/commit.rb', line 11
def initialize(base, sha)
super(base, sha)
end
|
Class Method Details
.diff_shortstat(base, to, from) ⇒ Object
28
29
30
31
32
33
34
35
|
# File 'lib/git_sniffer/commit.rb', line 28
def diff_shortstat(base, to, from)
result = Hash.new(0)
output = base.exec("diff --shortstat #{to.sha} #{from.sha}")
result[:file] = $1.to_i if output =~ /(\d+) files? changed/
result[:insert] = $1.to_i if output =~ /(\d+) insertions?\(\+\)/
result[:delete] = $1.to_i if output =~ /(\d+) deletions?\(-\)/
result
end
|
Instance Method Details
15
16
17
18
19
20
|
# File 'lib/git_sniffer/commit.rb', line 15
def blobs
result = @base.exec("ls-tree -r #{@sha}")
result.scan(/\d+ \w+ ([a-z\d]{40})\t.+\n/).collect do |line|
@base.object(line[0])
end
end
|
#diff_parent ⇒ Object
22
23
24
25
|
# File 'lib/git_sniffer/commit.rb', line 22
def diff_parent
return Hash.new(0) if parents.size == 0
self.class.diff_shortstat(@base, parents[0], self)
end
|