Created
December 9, 2009 22:49
-
-
Save cgriego/252922 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def detect(path) | |
git = File.directory?(File.join(path, '.git')) | |
svn = File.directory?(File.join(path, '.svn')) | |
hg = File.directory?(File.join(path, '.hg')) | |
bzr = File.directory?(File.join(path, '.bzr')) | |
case [git, svn, hg, bzr] | |
when [true, false, false, false] then SourceControl::Git.new(:path => path) | |
when [false, true, false, false] then SourceControl::Subversion.new(:path => path) | |
when [false, false, true, false] then SourceControl::Mercurial.new(:path => path) | |
when [false, false, false, true] then SourceControl::Bazaar.new(:path => path) | |
when [false, false, false, false] then raise "Could not detect the type of source control in #{path}" | |
else raise "More than one type of source control was detected in #{path}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment