Adds a bit of functionality to the clone command.

* You can give it user/repo style arguments for github repositories.
* If the repo has already been cloned into homes_dir, we don't try to clone again.
This commit is contained in:
Will Farrington
2010-03-04 01:30:30 -05:00
parent d183e93672
commit 9ff7737634

View File

@@ -7,7 +7,16 @@ class Homesick < Thor
def clone(uri)
empty_directory homes_dir
inside homes_dir do
run "git clone #{uri}"
if uri =~ /^git:\/\//
unless File.directory? "#{homes_dir}/#{uri[/[A-Za-z_-]+\/[A-Za-z_-]+$/]}"
run "git clone #{uri}"
end
elsif uri =~ /^[A-Za-z_-]+\/[A-Za-z_-]+$/
match = uri.match(/([A-Za-z_-]+)\/([A-Za-z_-]+)/)
unless File.directory? "#{homes_dir}/#{match[1]}_#{match[2]}"
run "git clone git://github.com/#{match[0]} #{match[1]}_#{match[2]}"
end
end
end
end