From afa6d004ff2a36f9a95fd17351bc67291bdf447f Mon Sep 17 00:00:00 2001 From: Tomasz Gieniusz Date: Fri, 19 Oct 2012 21:17:16 +0200 Subject: [PATCH] commits parsing moved to parser --- lib/git_stats/git_data/command_parser.rb | 7 +++++++ lib/git_stats/git_data/repo.rb | 14 ++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/git_stats/git_data/command_parser.rb b/lib/git_stats/git_data/command_parser.rb index 8b47187a6..a2dd64100 100644 --- a/lib/git_stats/git_data/command_parser.rb +++ b/lib/git_stats/git_data/command_parser.rb @@ -20,6 +20,13 @@ module GitStats end end + def parse_rev_list(result, params) + result.lines.map do |line| + hash, stamp, date, author_email = line.split('|').map(&:strip) + {hash: hash, stamp: stamp, date: date, author_email: author_email} + end + end + end end end \ No newline at end of file diff --git a/lib/git_stats/git_data/repo.rb b/lib/git_stats/git_data/repo.rb index febd820a1..044b612b5 100644 --- a/lib/git_stats/git_data/repo.rb +++ b/lib/git_stats/git_data/repo.rb @@ -21,12 +21,14 @@ module GitStats end def commits - @commits ||= run("git rev-list --pretty=format:'%h|%at|%ai|%aE' #{commit_range} | grep -v commit").lines.map do |commit_line| - hash, stamp, date, author_email = commit_line.split('|').map(&:strip) - author = authors.by_email(author_email) - - date = DateTime.parse(date) - Commit.new(repo: self, hash: hash, stamp: stamp, date: date, author: author) + @commits ||= run_and_parse("git rev-list --pretty=format:'%h|%at|%ai|%aE' #{commit_range} | grep -v commit").map do |commit_line| + Commit.new( + repo: self, + hash: commit_line[:hash], + stamp: commit_line[:stamp], + date: DateTime.parse(commit_line[:date]), + author: authors.by_email(commit_line[:author_email]) + ) end.sort_by! { |e| e.date }.extend(ByFieldFinder) end