Class: Gitlab::Git::LogParser
- Inherits:
-
Object
- Object
- Gitlab::Git::LogParser
- Defined in:
- lib/gitlab_git/log_parser.rb
Class Method Summary collapse
-
.parse_log(log_from_git) ⇒ Object
Parses the log file into a collection of commits Data model: date, additions, deletions.
Class Method Details
.parse_log(log_from_git) ⇒ Object
Parses the log file into a collection of commits Data model: date, additions, deletions
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/gitlab_git/log_parser.rb', line 6 def self.parse_log log_from_git log = log_from_git.split("\n") i = 0 collection = [] entry = {} while i <= log.size do pos = i % 4 case pos when 0 unless i == 0 collection.push(entry) entry = {} end entry[:author] = log[i].to_s when 1 entry[:date] = log[i].to_s when 3 changes = log[i].split(",") entry[:additions] = changes[1].to_i unless changes[1].nil? entry[:deletions] = changes[2].to_i unless changes[2].nil? end i += 1 end collection end |