mirror of
https://github.com/tomgi/git_stats.git
synced 2025-01-03 11:12:11 +01:00
lines_count speed up
This commit is contained in:
parent
9f6fab8232
commit
2d38d07e9f
4 changed files with 8 additions and 5 deletions
|
@ -7,7 +7,7 @@ class GitStats::CLI
|
|||
|
||||
repo_path, out_path = args
|
||||
GitStats::Generator.new(repo_path, out_path) { |g|
|
||||
g.git_command_observer { |command| puts command }
|
||||
g.git_command_observer { |command, result| puts "#{command}" }
|
||||
}.generate
|
||||
end
|
||||
|
||||
|
|
|
@ -9,8 +9,9 @@ module GitStats
|
|||
end
|
||||
|
||||
def run
|
||||
repo.git_command_observer.try(:call, @command)
|
||||
in_repo { %x[#@command] }
|
||||
result = in_repo { %x[#@command] }
|
||||
repo.git_command_observer.try(:call, @command, result)
|
||||
result
|
||||
end
|
||||
|
||||
def in_repo
|
||||
|
|
|
@ -20,7 +20,9 @@ module GitStats
|
|||
end
|
||||
|
||||
def lines_count
|
||||
@lines_count ||= files.map(&:lines_count).sum
|
||||
@lines_count ||= Command.new(repo, "git diff --shortstat `git hash-object -t tree /dev/null` #{self.hash}").run.lines.map do |line|
|
||||
line[/(\d+) insertions?/, 1].to_i
|
||||
end.sum
|
||||
end
|
||||
|
||||
def short_stat
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
%td= repo.commits.last.files_count
|
||||
%tr
|
||||
%td Total lines
|
||||
%td= "#{repo.commits.last.files.map(&:lines_count).sum} lines (#{repo.short_stats.map(&:insertions).sum} insertions, #{repo.short_stats.map(&:deletions).sum} deletions)"
|
||||
%td= "#{repo.commits.last.lines_count} lines (#{repo.short_stats.map(&:insertions).sum} insertions, #{repo.short_stats.map(&:deletions).sum} deletions)"
|
||||
%tr
|
||||
%td Total commits
|
||||
%td= repo.commits.size
|
||||
|
|
Loading…
Reference in a new issue