Sha256: 63932b2e4bd1291fb6a34634c1377c918b2701a32cdc19bb3aa28f63becc5bea

Contents?: true

Size: 774 Bytes

Versions: 1

Compression:

Stored size: 774 Bytes

Contents

module Gitlab
  module Git
    class LogParser
      # Parses the log file into a collection of commits
      # Data model:
      #   {author_name, author_email, date, additions, deletions}
      def self.parse_log(log_from_git)
        log = log_from_git.split("\n")
        collection = []

        log.each_slice(5) do |slice|
          entry = {}
          entry[:author_name] = slice[0]
          entry[:author_email] = slice[1]
          entry[:date] = slice[2]

          if slice[4]
            changes = slice[4]

            entry[:additions] = $1.to_i if changes =~ /(\d+) insertion/
            entry[:deletions] = $1.to_i if changes =~ /(\d+) deletion/
          end

          collection.push(entry)
        end

        collection
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gitlab_git-2.1.1 lib/gitlab_git/log_parser.rb