module GGSM::Switch
Public Instance Methods
process_switch(commit_not_exist, arry_conflict, branch, index, sub, sub_commits)
click to toggle source
# File lib/ggsm/command/switch.rb, line 54 def process_switch(commit_not_exist, arry_conflict, branch, index, sub, sub_commits) need_stash = try_stash `git checkout #{branch}`; result=$?.success? if result commit = sub_commits.fetch(index); `git reset --hard #{commit}`; result=$?.success? unless result commit_not_exist.push("==> #{sub}模块不存在远程commit:#{commit}") end else puts "[#{sub}] 没有#{branch}分支,创建并切换到#{branch}".blue system "git checkout -b #{branch}" end if need_stash stash_pop(arry_conflict, sub) end end
switch_flow(branch, is_sync = false)
click to toggle source
# File lib/ggsm/command/switch.rb, line 10 def switch_flow(branch, is_sync = false) check_submodule check_submodule_status(is_sync) puts '==> 进入主工程:'.yellow arry_conflict = [] arry_commit_not_exist = [] need_stash = try_stash `git checkout #{branch}`; result=$?.success? if need_stash stash_pop(arry_conflict, '主工程') end unless result return end sub_commits = get_submodule_commit foreach_module {|sub, index| if is_sync `git fetch | grep 'ignored'` end process_switch(arry_commit_not_exist, arry_conflict, branch, index, sub, sub_commits) } if arry_conflict.size > 0 tip = "==> #{arry_conflict.size}个模块冲突:" arry_conflict.each do |sub| tip = "#{tip} #{sub}" end puts tip.red end if arry_commit_not_exist.size > 0 arry_commit_not_exist.each do |tip| puts tip.red end tip_contact_author end end