Class: GrokCLI::Git::Log
- Inherits:
-
Object
- Object
- GrokCLI::Git::Log
- Defined in:
- lib/grok_cli/git/log.rb
Defined Under Namespace
Classes: Entry
Instance Method Summary collapse
Instance Method Details
#execute(since_hours_ago:, domains:, author:) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# 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).().since("#{since_hours_ago} hours ago").reverse_each do |commit| uris = URI.extract(commit.) 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 |