Class: Abak::Flow::Commands::Publish

Inherits:
Object
  • Object
show all
Includes:
ANSI::Code
Defined in:
lib/abak-flow/commands/publish.rb

Instance Method Summary collapse

Instance Method Details

#run(args, options) ⇒ Object



7
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
# File 'lib/abak-flow/commands/publish.rb', line 7

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

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

  title = options.title || head.extract_title
  body  = options.body || head.extract_body

  pr = PullRequest.new(base: base, head: head, title: title, body: body)
  validate_request(pr)

  say white {
    Manager.locale.word(self, "updating",
      branch: bold { head },
      upstream: bold { "#{Manager.repository.origin}" })
  }

  head.update

  say white {
    Manager.locale.word(self, "publicating",
      branch: bold { "#{Manager.repository.origin.owner}:#{head}" },
      upstream: bold { "#{Manager.repository.origin}" })
  }

  publicate_request(pr)

  say green { pr.link }
end