Sha256: 6c5771542707001bceb5719da40f5836c6af1311e25e42bae97a0198fce11c89

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'eac_launcher/stereotype'
require 'eac_launcher/stereotypes/git'

module EacLauncher
  module Stereotypes
    class GitSubtree
      include EacLauncher::Stereotype

      class << self
        def match?(path)
          return false if other_git_stereotype?(path)
          return false unless other_nogit_stereotype?(path)
          parent = parent_git(path.parent_path)
          return false unless parent
          ::Git.open(parent.real).remote(path.real.basename).url ? true : false
        end

        def color
          :green
        end

        def parent_git(p)
          return nil unless p
          ::EacLauncher::Stereotypes::Git.match?(p) ? p : parent_git(p.parent_path)
        end

        def other_git_stereotype?(path)
          ::EacLauncher::Stereotypes::Git.match?(path) ||
            ::EacLauncher::Stereotypes::GitSubrepo.match?(path)
        end

        def other_nogit_stereotype?(path)
          EacLauncher::Stereotype.nogit_stereotypes.any? { |s| s.match?(path) }
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eac_launcher-0.6.0 lib/eac_launcher/stereotypes/git_subtree.rb