Module: GGSM::Start

Includes:
Stash, Submodule
Included in:
Cli
Defined in:
lib/ggsm/command/start.rb

Instance Method Summary collapse

Methods included from Stash

#stash_pop, #try_stash

Methods included from Submodule

#check_submodule, #check_submodule_status, #check_un_commit_code, #correct_dir, #foreach_module, #get_current_branch, #get_head_commit, #get_lastest_msg, #get_lastest_msg_not_merge, #get_lastest_msg_of_module, #get_modified_submodule, #get_submodule, #get_submodule_commit, #is_submodule, #tip_contact_author

Methods included from Hooks

#check_hooks, #cp_files, #cp_hooks, #install_billow, #update_hooks

Instance Method Details

#start_flow(branch, action) ⇒ Object



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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/ggsm/command/start.rb', line 10

def start_flow(branch, action)
  check_submodule

  puts '==> 进入主工程:'.yellow

  arry_conflict = []
  current_branch = get_current_branch

  need_stash = try_stash
  if action.start_with?('origin/')
    need_fetch = `git fetch`
    if need_fetch != ''
      `git submodule foreach git fetch | grep 'ignored'`
    end
  end
  result = system "git checkout -b #{branch} #{action}"
  if need_stash
    stash_pop(arry_conflict, '主工程')
  end

  unless result
    return
  end

  result = system 'git submodule update --init --recursive'
  unless result
    tip_contact_author
    `git checkout #{current_branch};git branch -D #{branch}`
    return
  end

  foreach_module {|sub|
    need_stash = try_stash
    system "git checkout -b #{branch}"
    if need_stash
      stash_pop(arry_conflict, sub)
    end
  }

  if arry_conflict.size > 0
    tip = "==> #{arry_conflict.size}个模块冲突:"
    arry_conflict.each do |sub|
      tip = "#{tip}  #{sub}"
    end
    puts tip.red
  end
end