From 9ff7737634997bdb5702023ec4c8bfd19c3de4ef Mon Sep 17 00:00:00 2001 From: Will Farrington Date: Thu, 4 Mar 2010 01:30:30 -0500 Subject: [PATCH] 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. --- lib/homesick.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index b193fd4..ec31a49 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -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