Class: Avm::Projects::Stereotypes::GitSubtree

Inherits:
Object
  • Object
show all
Includes:
Avm::Projects::Stereotype
Defined in:
lib/avm/projects/stereotypes/git_subtree.rb,
lib/avm/projects/stereotypes/git_subtree/warp.rb,
lib/avm/projects/stereotypes/git_subtree/publish.rb

Defined Under Namespace

Classes: Publish, Warp

Class Method Summary collapse

Methods included from Avm::Projects::Stereotype

git_stereotypes, included, nogit_stereotypes

Class Method Details

.colorObject



25
26
27
# File 'lib/avm/projects/stereotypes/git_subtree.rb', line 25

def color
  :green
end

.match?(path) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
22
23
# File 'lib/avm/projects/stereotypes/git_subtree.rb', line 15

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

.other_git_stereotype?(path) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
42
# File 'lib/avm/projects/stereotypes/git_subtree.rb', line 39

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

.other_nogit_stereotype?(path) ⇒ Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/avm/projects/stereotypes/git_subtree.rb', line 44

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

.parent_git(parent_path) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/avm/projects/stereotypes/git_subtree.rb', line 29

def parent_git(parent_path)
  return nil unless parent_path

  if ::Avm::Projects::Stereotypes::Git.match?(parent_path)
    parent_path
  else
    parent_git(parent_path.parent_path)
  end
end