20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/git-blame-color/application.rb', line 20
def run(argv)
Rainbow.enabled = true
die 1, 'git blame-color does not support the --incremental option' if ARGV.incremental?
stdout, stderr, status = Open3.capture3('git', 'blame', '--line-porcelain', *ARGV)
die status.exitstatus, stderr unless status.success?
lines = stdout.split($/)
stats = nil
if ARGV.show_stats?
stats = lines.last(3)
lines = lines.drop_last(3)
end
commits = parse_commits(lines, [])
author_width = longest_author_name_width(commits)
line_width = max_line_number_width(commits)
opts = {
:show_boundary_commits => !ARGV.blank_boundary_commits?,
:long_hashes => ARGV.long_hash?,
:raw_timestamps => ARGV.raw_timestamps?,
}
formatter = Git::BlameColor::Formatter.new(author_width, line_width, opts)
page
commits.each do |c|
puts formatter.format(c)
end
puts stats.join("\n") if stats
end
|