Class: Thicket::Log

Inherits:
Object
  • Object
show all
Defined in:
lib/thicket/log.rb

Constant Summary collapse

LOG_PARSE_REGEX =
/[a-f0-9]{7}.+?m(.+?) .+?m\{(.+?)\}.+?m (?:\((.+?)\))?.+?m(.+$)/.freeze

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Log

Returns a new instance of Log.



10
11
12
13
# File 'lib/thicket/log.rb', line 10

def initialize(options)
  @options = options
  @count_parsed = 0
end

Instance Method Details

Gets a printable version of the log for purposes of printing to a terminal. This effectively builds the final printable log to display to the user.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/thicket/log.rb', line 18

def print
  FileUtils.cd(git_working_directory)
  `#{git_log_command}`.encode("UTF-8", invalid: :replace, undef: :replace)
                      .split("\n")
                      .each do |l|
    puts process_git_log_line(l)

    next unless @options[:limit] && @count_parsed >= @options[:limit]

    puts "..."
    puts "Stopped after #{@options[:limit]} commits. More commit history exists."
    exit
  end
rescue Errno::EPIPE, SystemExit, Interrupt
  exit
end