Method: Sunshine::Repo.detect

Defined in:
lib/sunshine/repo.rb

.detect(path = ".", shell = nil) ⇒ Object

Looks for .git and .svn directories and determines if the passed path is a recognized repo. Does not check for RsyncRepo since it’s a special case. Returns the appropriate repo object:

Repo.detect "path/to/svn/repo/dir"
  #=> <SvnRepo @url="svn://url/of/checked/out/repo">
Repo.detect "path/to/git/repo/dir"
  #=> <GitRepo, @url="git://url/of/git/repo", @branch="master">
Repo.detect "invalid/repo/path"
  #=> nil


55
56
57
58
59
60
61
62
63
64
# File 'lib/sunshine/repo.rb', line 55

def self.detect path=".", shell=nil
  @@repo_types.values.each do |repo|
    if repo.valid? path
      info = repo.get_info path, shell
      return repo.new(info[:url], info)
    end
  end

  nil
end