class GrokCLI::Git::Log
Public Instance Methods
execute(since_hours_ago:, domains:, author:)
click to toggle source
# File lib/grok_cli/git/log.rb, line 8 def execute(since_hours_ago:, domains:, author:) pwd = Dir.pwd git = Git.open(pwd) map = {} git.log(1_000_000).author(author).since("#{since_hours_ago} hours ago").reverse_each do |commit| uris = URI.extract(commit.message) uris.select! do |uri| uri.match(domains) ? true : false end if uris.empty? map['No Ticket'] ||= [] else uris.each do |uri| map[uri] ||= [] end end if uris.empty? map['No Ticket'] << commit else uris.each do |uri| map[uri] << commit end end end entries = map.map do |ticket, commits| Entry.new(ticket: ticket, commits: commits).to_s end puts entries.join("\n#{'-'*72}\n\n") end