diff --git a/lib/homesick.rb b/lib/homesick.rb index e8acea2..0a6eb08 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -75,9 +75,11 @@ class Homesick < Thor desc "list", "List cloned castles" def list - Pathname.glob(repos_dir + "*") do |castle| + #require 'ruby-debug'; breakpoint + Pathname.glob("#{repos_dir}/**/*/.git") do |git_dir| + castle = git_dir.dirname Dir.chdir castle do # so we can call git config from the right contxt - say_status castle.basename.to_s, `git config remote.origin.url`.chomp, :cyan + say_status castle.relative_path_from(repos_dir), `git config remote.origin.url`.chomp, :cyan end end end diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index 3064ab1..c1ccf0f 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -11,10 +11,11 @@ describe Homesick do somewhere.directory('wtf') wtf = somewhere + 'wtf' - @homesick.should_receive(:ln_s).with(wtf.to_s, wtf.basename.to_s) + @homesick.should_receive(:ln_s).with(wtf.to_s, wtf.basename) @homesick.clone wtf.to_s end + it "should clone git repo like git://host/path/to.git" do @homesick.should_receive(:git_clone).with('git://github.com/technicalpickles/pickled-vim.git') @@ -34,7 +35,7 @@ describe Homesick do end it "should clone a github repo" do - @homesick.should_receive(:git_clone).with('git://github.com/wfarr/dotfiles.git', :destination => 'wfarr/dotfiles') + @homesick.should_receive(:git_clone).with('git://github.com/wfarr/dotfiles.git', :destination => Pathname.new('wfarr/dotfiles')) @homesick.clone "wfarr/dotfiles" end @@ -51,9 +52,17 @@ describe Homesick do system "git remote add origin git://github.com/technicalpickles/zomg.git >/dev/null 2>&1" end end + + repos_dir.directory 'wtf/zomg' do |zomg| + Dir.chdir do + system "git init >/dev/null 2>&1" + system "git remote add origin git://github.com/technicalpickles/zomg.git >/dev/null 2>&1" + end + end end @homesick.should_receive(:say_status).with("zomg", "git://github.com/technicalpickles/zomg.git", :cyan) + @homesick.should_receive(:say_status).with("wtf/zomg", "git://github.com/technicalpickles/zomg.git", :cyan) @homesick.list end