Sha256: 534fb15488d2dd2bd459af07e9cc7d74b918d245330a181711e5039b5e6787f9

Contents?: true

Size: 908 Bytes

Versions: 3

Compression:

Stored size: 908 Bytes

Contents

module GGSM
  module Submodule
    def check_submodule
      sub_str = `git submodule`
      if sub_str.empty?
        puts '所在目录工程下不存在Submodule,请检查所在目录!'.red
        return false
      end
      return true
    end

    def get_submodule
      sub_status = `git submodule`
      pattern = /(?<=\s)[0-9a-zA-Z]*(?=\s)/
      sub_status = sub_status.split(/\n/)

      result = []
      sub_status.each do |sub|
        match = pattern.match(sub.strip)
        result.push(match[0])
      end
      return result
    end

    def get_submodule_commit
      sub_commits = `git ls-tree HEAD | grep "160000"`
      pattern = /(?<=\s)[0-9a-zA-Z]{40}(?=\s)/
      sub_commits = sub_commits.split(/\n/)
      result = []
      sub_commits.each do |sub|
        match = pattern.match(sub.strip)
        result.push(match[0][0...7])
      end
      return result
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ggsm-1.0.2 lib/ggsm/util/submodule.rb
ggsm-1.0.1 lib/ggsm/util/submodule.rb
ggsm-1.0.0 lib/ggsm/util/submodule.rb