Sha256: df4f54f8975bd187b53424572b03a298fe5d8d1bf122a43c7c70bbdb00d14857

Contents?: true

Size: 899 Bytes

Versions: 4

Compression:

Stored size: 899 Bytes

Contents

module GitWakaTime
  # Th
  class Mapper
    attr_accessor :commits, :git
    def initialize(commits: 500, start_at: Date.today)
      Log.new 'Mapping commits for dependent commits'
      time = Benchmark.realtime do
        g = GitWakaTime.config.git
        project = File.basename(g.dir.path)
        logs =  g.log(commits).since(start_at).until(Date.today)

        @commits = logs.map do |git_c|
          next if git_c.author.name != GitWakaTime.config.user_name
          next if git_c.parents.size > 1
          Commit.find_or_create(
             sha: git_c.sha,
             project: project
             ) do |c|
            c.update(
             author: git_c.author.name,
             message: git_c.message,
             date: git_c.date.utc
            )
          end
        end.compact
      end
      Log.new "Map Completed took #{time}s with #{Commit.count}"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gitwakatime-0.2.2 lib/gitwakatime/mapper.rb
gitwakatime-0.2.1 lib/gitwakatime/mapper.rb
gitwakatime-0.2.0 lib/gitwakatime/mapper.rb
gitwakatime-0.1.2 lib/gitwakatime/mapper.rb