Sha256: 722dc4065346446dd0b27c6a3c4576f1f46db0f169cd00a6695e749891307bd2

Contents?: true

Size: 850 Bytes

Versions: 2

Compression:

Stored size: 850 Bytes

Contents

require 'colorize'
require_relative '../util/submodule'
require_relative '../util/stash'

module GGSM
  module Foreach
    include Submodule
    include Stash

    def foreach_flow(*commands)
      unless check_submodule
        return
      end

      cmd = ''
      if commands.size == 0
        puts '请输入正确git命令 foreach [<commands>...]'.red
        return
      elsif commands.fetch(0) == 'git'
        commands.delete_at(0)
      end

      commands.each do |arg|
        cmd = "#{cmd} #{arg}"
      end
      puts cmd

      subs = get_submodule
      subs.each do |sub|
        Dir.chdir sub
        puts "==> *进入#{sub}:".yellow
        system "git #{cmd}"
        Dir.chdir '..'
      end

      puts '==> *进入主工程:'.yellow
      system "git #{cmd}"

      puts "Modules执行:git#{cmd}".blue
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ggsm-1.0.1 lib/ggsm/flow/foreach.rb
ggsm-1.0.0 lib/ggsm/flow/foreach.rb