commits parsing moved to parser

This commit is contained in:
Tomasz Gieniusz 2012-10-19 21:17:16 +02:00
parent b439fd234c
commit afa6d004ff
2 changed files with 15 additions and 6 deletions

View file

@ -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

View file

@ -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