Sha256: 5409704ade843ba5c9d4a086475f47dd2b96c8244a007faf5cb225387f5f5d22

Contents?: true

Size: 1.16 KB

Versions: 26

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

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(parent_path)
          return nil unless parent_path

          if ::EacLauncher::Stereotypes::Git.match?(parent_path)
            parent_path
          else
            parent_git(parent_path.parent_path)
          end
        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

26 entries across 26 versions & 2 rubygems

Version Path
avm-tools-0.58.1 lib/eac_launcher/stereotypes/git_subtree.rb
avm-tools-0.58.0 lib/eac_launcher/stereotypes/git_subtree.rb
avm-tools-0.57.0 lib/eac_launcher/stereotypes/git_subtree.rb
avm-tools-0.56.0 lib/eac_launcher/stereotypes/git_subtree.rb
avm-tools-0.55.0 lib/eac_launcher/stereotypes/git_subtree.rb
avm-tools-0.54.2 lib/eac_launcher/stereotypes/git_subtree.rb
avm-tools-0.54.1 lib/eac_launcher/stereotypes/git_subtree.rb
avm-tools-0.54.0 lib/eac_launcher/stereotypes/git_subtree.rb
avm-tools-0.53.0 lib/eac_launcher/stereotypes/git_subtree.rb
avm-tools-0.52.0 lib/eac_launcher/stereotypes/git_subtree.rb
avm-tools-0.51.0 lib/eac_launcher/stereotypes/git_subtree.rb
avm-tools-0.50.0 lib/eac_launcher/stereotypes/git_subtree.rb
avm-tools-0.49.0 lib/eac_launcher/stereotypes/git_subtree.rb
avm-tools-0.48.0 lib/eac_launcher/stereotypes/git_subtree.rb
avm-tools-0.47.0 lib/eac_launcher/stereotypes/git_subtree.rb
avm-tools-0.46.0 lib/eac_launcher/stereotypes/git_subtree.rb
eac_launcher-0.8.0 lib/eac_launcher/stereotypes/git_subtree.rb
eac_launcher-0.7.0 lib/eac_launcher/stereotypes/git_subtree.rb
eac_launcher-0.6.8 lib/eac_launcher/stereotypes/git_subtree.rb
eac_launcher-0.6.7 lib/eac_launcher/stereotypes/git_subtree.rb