Class: HTools::Gt::Rbs

Inherits:
Object
  • Object
show all
Defined in:
lib/h_tools/gt/rbs.rb

Class Method Summary collapse

Class Method Details

.call(parent_branch, working_branch) ⇒ 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
# File 'lib/h_tools/gt/rbs.rb', line 7

def call(parent_branch, working_branch)
  working_branch_bak = "#{working_branch}-bak"

  last_commit_cmd = "git rev-parse HEAD"

  [
    "git checkout #{working_branch}",
    "git checkout -b #{working_branch_bak}",
    "git branch -D #{working_branch}"
  ].each { |command| perform(command) }

  confirmation(last_commit_cmd)
  last_commit = `#{last_commit_cmd}`
  puts last_commit.yellow

  [
    "git checkout #{parent_branch}",
    "git pull origin #{parent_branch}",
    "git checkout -b #{working_branch}",
    "git cherry-pick #{last_commit}"
  ].each { |command| perform(command) }

  puts 'Hope all right, bye!'.blue
end