Module: GGSM::Merge

Includes:
Submodule
Included in:
Cli
Defined in:
lib/ggsm/command/merge.rb

Instance Method Summary collapse

Methods included from Submodule

#check_submodule, #check_submodule_status, #check_un_commit_code, #correct_dir, #foreach_module, #get_current_branch, #get_modified_submodule, #get_submodule, #get_submodule_commit, #tip_contact_author

Methods included from Hooks

#check_hooks, #cp_files, #cp_hooks, #update_hooks

Instance Method Details

#merge_flow(branch) ⇒ Object



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

def merge_flow(branch)
  check_submodule
  check_un_commit_code

  arry_conflict = []

  foreach_module {|sub|
    process_merge(arry_conflict, sub, branch)
  }

  puts '==> 进入主工程:'.yellow
  process_rebase(arry_conflict, branch)
  puts "Modules执行:git merge #{branch}".blue

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

#process_merge(arry_conflict, module_name, branch) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/ggsm/command/merge.rb', line 31

def process_merge(arry_conflict, module_name, branch)
  result_merge = `git merge #{branch}`
  puts result_merge

  if result_merge.include? 'Merge conflict'
    arry_conflict.push(module_name)
  end
end

#process_rebase(arry_conflict, branch) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/ggsm/command/merge.rb', line 40

def process_rebase(arry_conflict, branch)
  result_merge = `git rebase #{branch}`
  puts result_merge

  if result_merge.include? 'Merge conflict'
    arry_conflict.push('主工程')
  end
end