Module: Avm::Git::Launcher::Base::ClassMethods

Included in:
Avm::Git::Launcher::Base
Defined in:
lib/avm/git/launcher/base/class_methods.rb

Instance Method Summary collapse

Instance Method Details

#by_root(search_base_path) ⇒ Avm::Git::Launcher::Base



9
10
11
# File 'lib/avm/git/launcher/base/class_methods.rb', line 9

def by_root(search_base_path)
  new(find_root(search_base_path).to_path)
end

#find_root(search_base_path) ⇒ Pathname

Searches the root path for the Git repository which includes search_base_path.

Returns:

  • (Pathname)


15
16
17
18
19
20
21
22
23
# File 'lib/avm/git/launcher/base/class_methods.rb', line 15

def find_root(search_base_path)
  path = search_base_path.to_pathname.expand_path
  loop do
    return path if path.join('.git').exist?
    raise "\".git\" not found for \"#{search_base_path}\"" if path.parent.root?

    path = path.parent
  end
end