Method: BigKeeper::ModuleService#verify_module

Defined in:
lib/big_keeper/service/module_service.rb

#verify_module(path, user, module_name, home_branch_name, type) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/big_keeper/service/module_service.rb', line 8

def verify_module(path, user, module_name, home_branch_name, type)
  name = home_branch_name.gsub(/#{GitflowType.name(type)}\//, '')
  module_full_path = BigkeeperParser.module_full_path(path, user, module_name)

  git = GitOperator.new
  if !File.exist? module_full_path
    Logger.default("No local repository for module '#{module_name}', clone it...")
    module_git = BigkeeperParser.module_git(module_name)
    git.new.clone(File.expand_path("#{module_full_path}/../"), module_git)
  end

  current_branch_name = git.current_branch(module_full_path)
  if current_branch_name != home_branch_name
    # stash current branch
    StashService.new.stash(module_full_path, current_branch_name, module_name)

    GitService.new.start(module_full_path, name, type)

    StashService.new.pop_stash(module_full_path, home_branch_name, module_name)
  end
end