Sha256: b59cbe0cc4b93996c0b74cdc46fc2a0a20e1d2490fcd5e564f4988e0cc1a1e48
Contents?: true
Size: 1.25 KB
Versions: 37
Compression:
Stored size: 1.25 KB
Contents
module OhlohScm::Adapters class Factory # Given a local path on disk, try to guess what kind of repository it is, # and return an appropriate adapter. def self.from_path(path) if FileTest.exist?(File.join(path, '.git')) GitAdapter.new(:url => File.expand_path(path)).normalize elsif FileTest.exist?(File.join(path, '.hg')) HgAdapter.new(:url => File.expand_path(path)).normalize elsif FileTest.exist?(File.join(path, '.bzr')) BzrAdapter.new(:url => File.expand_path(path)).normalize elsif FileTest.exist?(File.join(path, 'db')) SvnAdapter.new(:url => File.expand_path(path)).normalize elsif FileTest.exist?(File.join(path, '.svn')) # It's a local checkout. Use the secret info stashed by Subversion to find the server URL. info = `cd #{path} && svn info` if info =~ /^URL: (.+)$/ svn = SvnAdapter.new(:url => $1).normalize svn.recalc_branch_name svn end elsif FileTest.exist?(File.join(path, 'CVS', 'Root')) # It's a local CVS checkout. Use the secret info to find the server URL. root = File.read(File.join(path, 'CVS', 'Root')).strip repo = File.read(File.join(path, 'CVS', 'Repository')).strip CvsAdapter.new(:url => root, :repository => repo).normalize end end end end
Version data entries
37 entries across 37 versions & 1 rubygems