class Monolith::BranchPreparer
Constants
- COMMIT
Public Class Methods
new(repo, branch)
click to toggle source
# File lib/monolith/branch_preparer.rb 9 def initialize(repo, branch) 10 @repo = repo 11 @branch = branch 12 end
Public Instance Methods
prepare()
click to toggle source
# File lib/monolith/branch_preparer.rb 14 def prepare 15 within_working_dir do 16 checkout_branch 17 hard_reset_branch 18 create_subdir 19 move_files_under_subdir 20 commit_changes 21 end 22 end
Private Instance Methods
checkout_branch()
click to toggle source
# File lib/monolith/branch_preparer.rb 26 def checkout_branch 27 run!("branch #{@branch.name} || true") 28 run!("checkout #{@branch.name}") 29 end
commit_changes()
click to toggle source
# File lib/monolith/branch_preparer.rb 45 def commit_changes 46 message = COMMIT % @branch.path 47 run!("commit -m '#{message}'") 48 end
create_subdir()
click to toggle source
# File lib/monolith/branch_preparer.rb 35 def create_subdir 36 LoggedMkdir.new(@repo.name).mkdir 37 end
hard_reset_branch()
click to toggle source
# File lib/monolith/branch_preparer.rb 31 def hard_reset_branch 32 run!("reset --hard origin/#{@branch.name}") 33 end
move_files_under_subdir()
click to toggle source
# File lib/monolith/branch_preparer.rb 39 def move_files_under_subdir 40 files = "ls-tree HEAD | cut -f 2" 41 move = "xargs -I file git mv file #{@repo.name}/file" 42 run!("#{files} | #{move}") 43 end