Sha256: 9b8c3a53396bc8d32a1826afd5fdee640562f20af704cc44e78ac622ac7ec646
Contents?: true
Size: 1.96 KB
Versions: 7
Compression:
Stored size: 1.96 KB
Contents
require 'colorize' require_relative '../util/submodule' module DNGG module Finish include Submodule def finish_flow(force) check_submodule foreach_module { process_finish(false) } puts '==> 进入主工程:'.yellow process_finish(force, get_main_project_msg) puts 'Modules执行:git add & commit & push'.blue end def process_finish(force, msg='') system 'git add .' branch = get_current_branch if branch.include?('rebas') system 'git rebase --continue' else stage = `git diff --cached --name-only`.strip if stage == '' `git commit` else if msg == '' result = system 'git commit' else result = system "git commit -m \"#{msg}\"" end unless result exit 1 end end end `git push -u origin #{get_current_branch} #{force ? '-f' : ''}` end def get_main_project_msg() system 'git add .' pattern = /[A-Z]\s*(.*)/ result = `git status -s | grep -e '[A-Z].*'`.split(/\n/).delete_if do |r| r == '' end modified = [] result.each do |r| if match = r.match(pattern) module_name = match[1].strip if is_submodule(module_name) modified.push(match[1].strip) end end end whole_files = `git status -s`.split(/\n/).delete_if do |w| w == '' end return '' if whole_files.length != modified.length outputs = '' modified.each_with_index do |m, index| msg = get_lastest_msg_of_module(m) if msg.index(':') outputs += msg.insert(msg.index(':') + 1, "[#{get_module_name(m)}]") end if index != modified.length - 1 outputs += "\n" end end puts outputs outputs end def get_module_name(module_name) module_name.split(/\//).last end end end
Version data entries
7 entries across 7 versions & 1 rubygems