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

Version Path
ohloh_scm-2.5.1 lib/ohloh_scm/adapters/factory.rb
ohloh_scm-2.4.14 lib/ohloh_scm/adapters/factory.rb
ohloh_scm-2.4.13 lib/ohloh_scm/adapters/factory.rb
ohloh_scm-2.4.12 lib/ohloh_scm/adapters/factory.rb
ohloh_scm-2.4.11 lib/ohloh_scm/adapters/factory.rb
ohloh_scm-2.4.10 lib/ohloh_scm/adapters/factory.rb
ohloh_scm-2.4.9 lib/ohloh_scm/adapters/factory.rb
ohloh_scm-2.4.8 lib/ohloh_scm/adapters/factory.rb
ohloh_scm-2.4.7 lib/ohloh_scm/adapters/factory.rb
ohloh_scm-2.4.6 lib/ohloh_scm/adapters/factory.rb
ohloh_scm-2.4.5 lib/ohloh_scm/adapters/factory.rb
ohloh_scm-2.4.4 lib/ohloh_scm/adapters/factory.rb
ohloh_scm-2.4.3 lib/ohloh_scm/adapters/factory.rb
ohloh_scm-2.4.1 lib/ohloh_scm/adapters/factory.rb
ohloh_scm-2.4.0 lib/ohloh_scm/adapters/factory.rb
ohloh_scm-2.3.5 lib/ohloh_scm/adapters/factory.rb
ohloh_scm-2.3.4 lib/ohloh_scm/adapters/factory.rb
ohloh_scm-2.3.2 lib/ohloh_scm/adapters/factory.rb
ohloh_scm-2.3.1 lib/ohloh_scm/adapters/factory.rb
ohloh_scm-2.3.0 lib/ohloh_scm/adapters/factory.rb