class Monolith::BranchMerger

Public Class Methods

new(monolith, repo, branch) click to toggle source
   # File lib/monolith/branch_merger.rb
 7 def initialize(monolith, repo, branch)
 8   @monolith = monolith
 9   @repo = repo
10   @branch = branch
11 end

Public Instance Methods

merge() click to toggle source
   # File lib/monolith/branch_merger.rb
13 def merge
14   within_working_dir do
15     checkout_branch
16     fetch_and_pull_branch
17     checkout_previous_branch
18   end
19 end

Private Instance Methods

checkout_branch() click to toggle source
   # File lib/monolith/branch_merger.rb
23 def checkout_branch
24   run!("branch #{@branch} || true")
25   run!("checkout #{@branch}")
26 end
checkout_previous_branch() click to toggle source
   # File lib/monolith/branch_merger.rb
38 def checkout_previous_branch
39   run!("checkout -")
40 end
fetch_and_pull_branch() click to toggle source
   # File lib/monolith/branch_merger.rb
28 def fetch_and_pull_branch
29   run!("fetch #{@repo.name} #{@branch}")
30   run!("pull #{@repo.name} #{@branch}")
31 rescue
32   run!("fetch #{@repo.name} master")
33   run!("pull #{@repo.name} master")
34 ensure
35   run!("commit --amend -m '[monolith] Merging #{@repo.name}/master'")
36 end