Sha256: f6f0647acbf0e3585c61844d11b8ba18b34c75a9f63f68e5110f6320255ae474
Contents?: true
Size: 1.34 KB
Versions: 19
Compression:
Stored size: 1.34 KB
Contents
require_relative '../util/submodule' require_relative '../util/stash' module GGSM module Delete include Submodule include Stash def delete_flow(branch, remote, all) check_submodule puts '==> 进入主工程:'.yellow delete_branch(all, branch, remote) foreach_module { delete_branch(all, branch, remote) } end def delete_branch(all, branch, remote) if branch == get_current_branch puts "无法删除当前所在分支:#{branch},请switch其他分支后再执行\"ggsm delete\"".red exit 0 end if all delete_local_branch(branch) delete_remote_branch(branch) elsif remote delete_remote_branch(branch) else delete_local_branch(branch) end end def delete_local_branch(branch) if `git branch | grep -e '\s|*#{branch}$'`.strip == '' puts "warning: branch '#{branch}' not found" else info = `git branch -D #{branch}` if info.strip != '' puts "✓ #{info}" end end end def delete_remote_branch(branch) if `git branch -r | grep -e '\s|*origin/#{branch}$'`.strip == '' puts "warning: remote branch '#{branch}' not found" else system "git push origin -d #{branch}" `git fetch -p origin` end end end end
Version data entries
19 entries across 19 versions & 1 rubygems