Sha256: 112d0f5a92ed02937f1b098bb605c5ab693e0199a00055111c0ebd09514bd4f4

Contents?: true

Size: 855 Bytes

Versions: 2

Compression:

Stored size: 855 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
          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
            )
          end
        end.compact
      end
      Log.new "Map Completed took #{time}s with #{Commit.count}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gitwakatime-0.1.1 lib/gitwakatime/mapper.rb
gitwakatime-0.1.0 lib/gitwakatime/mapper.rb