Sha256: 7b4de97cede1ea800a66b83fcf3422f3c82abe4f45704e442c172179cc43eddd
Contents?: true
Size: 1.79 KB
Versions: 12
Compression:
Stored size: 1.79 KB
Contents
require 'colorize' require_relative '../util/submodule' require_relative '../util/stash' module DNGG module Switch include Submodule include Stash 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 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 end end
Version data entries
12 entries across 12 versions & 1 rubygems