Fix listing of github-style cloned repos.

This commit is contained in:
Joshua Nichols
2010-05-18 20:42:45 -04:00
parent f0c67f9653
commit 3efee55f03
2 changed files with 15 additions and 4 deletions

View File

@@ -75,9 +75,11 @@ class Homesick < Thor
desc "list", "List cloned castles" desc "list", "List cloned castles"
def list 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 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 end
end end

View File

@@ -11,10 +11,11 @@ describe Homesick do
somewhere.directory('wtf') somewhere.directory('wtf')
wtf = somewhere + '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 @homesick.clone wtf.to_s
end end
it "should clone git repo like git://host/path/to.git" do 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') @homesick.should_receive(:git_clone).with('git://github.com/technicalpickles/pickled-vim.git')
@@ -34,7 +35,7 @@ describe Homesick do
end end
it "should clone a github repo" do 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" @homesick.clone "wfarr/dotfiles"
end end
@@ -51,9 +52,17 @@ describe Homesick do
system "git remote add origin git://github.com/technicalpickles/zomg.git >/dev/null 2>&1" system "git remote add origin git://github.com/technicalpickles/zomg.git >/dev/null 2>&1"
end end
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 end
@homesick.should_receive(:say_status).with("zomg", "git://github.com/technicalpickles/zomg.git", :cyan) @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 @homesick.list
end end