Class: Command::Log

Inherits:
Base
  • Object
show all
Includes:
PrintDiff
Defined in:
lib/command/log.rb

Constant Summary

Constants included from PrintDiff

PrintDiff::DIFF_FORMATS, PrintDiff::NULL_OID, PrintDiff::NULL_PATH

Instance Attribute Summary

Attributes inherited from Base

#status

Instance Method Summary collapse

Methods included from PrintDiff

#define_print_diff_options

Methods inherited from Base

#execute, #initialize

Constructor Details

This class inherits a constructor from Command::Base

Instance Method Details

#define_optionsObject



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
44
45
46
47
# File 'lib/command/log.rb', line 10

def define_options
  @rev_list_opts = {}
  @parser.on("--all")      { @rev_list_opts[:all]      = true }
  @parser.on("--branches") { @rev_list_opts[:branches] = true }
  @parser.on("--remotes")  { @rev_list_opts[:remotes]  = true }

  @options[:decorate] = "auto"
  @options[:abbrev]   = :auto
  @options[:format]   = "medium"
  @options[:patch]    = false

  define_print_diff_options

  @parser.on "--decorate[=<format>]" do |format|
    @options[:decorate] = format || "short"
  end

  @parser.on "--no-decorate" do
    @options[:decorate] = "no"
  end

  @parser.on "--[no-]abbrev-commit" do |value|
    @options[:abbrev] = value
  end

  @parser.on "--pretty=<format>", "--format=<format>" do |format|
    @options[:format] = format
  end

  @parser.on "--oneline" do
    @options[:abbrev] = true if @options[:abbrev] == :auto
    @options[:format] = "oneline"
  end

  @parser.on "--cc" do
    @options[:combined] = @options[:patch] = true
  end
end

#runObject



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/command/log.rb', line 49

def run
  setup_pager

  @reverse_refs = repo.refs.reverse_refs
  @current_ref  = repo.refs.current_ref

  @rev_list = ::RevList.new(repo, @args, @rev_list_opts)
  @rev_list.each { |commit| show_commit(commit) }

  exit 0
end