Sha256: bdb159216186c5a45863e1feebc4d94e1814d3c4e502b04282d0b53ed3a24a96

Contents?: true

Size: 877 Bytes

Versions: 5

Compression:

Stored size: 877 Bytes

Contents

module Gitlab
  module Git
    class LogParser
      # Parses the log file into a collection of commits
      # Data model: {author, date, additions, deletions}
      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
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gitlab_git-1.3.1 lib/gitlab_git/log_parser.rb
gitlab_git-2.0.0.pre lib/gitlab_git/log_parser.rb
gitlab_git-1.4.1 lib/gitlab_git/log_parser.rb
gitlab_git-1.4.0 lib/gitlab_git/log_parser.rb
gitlab_git-1.3.0 lib/gitlab_git/log_parser.rb