Class: Abak::Flow::Commands::Compare

Inherits:
Object
  • Object
show all
Defined in:
lib/abak-flow/commands/compare.rb

Instance Method Summary collapse

Constructor Details

#initializeCompare

TODO : Быть может стоит сделать include ANSI



10
11
12
13
14
15
16
# File 'lib/abak-flow/commands/compare.rb', line 10

def initialize
  manager = Manager.instance

  @configuration = manager.configuration
  @repository = manager.repository
  @git = manager.git
end

Instance Method Details

#run(args, options) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/abak-flow/commands/compare.rb', line 18

def run(args, options)
  Checkup.new.process(
    Array.new, ::Commander::Command::Options.new)

  current = @git.current_branch
  head = Branch.new(options.head || current)
  base = Branch.new(options.base || head.extract_base_name)

  if head.current?
    say ANSI.white {
      I18n.t("commands.compare.updating",
        branch: ANSI.bold { head },
        upstream: ANSI.bold { "#{@repository.origin}" }) }

    head.update
  else
    say ANSI.yellow {
      I18n.t("commands.compare.diverging",
        branch: ANSI.bold { head }) }
  end

  say ANSI.green { head.compare_link(base) }
end