From c3f6bef15256a059dde20d36c10fee80886669f4 Mon Sep 17 00:00:00 2001 From: Ilkka Laukkanen Date: Wed, 27 Apr 2011 21:39:02 +0300 Subject: [PATCH] Don't treat git repos in other repos as castles Further abstracted locating castles into Homesick.all_castles which globs as before, but after that rejects any paths that lie in other paths. This way castles that have submodules don't cause extra output in e.g. list. --- lib/homesick.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index 9733d37..7a96695 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -157,8 +157,16 @@ class Homesick < Thor end end + def all_castles + dirs = Pathname.glob("#{repos_dir}/**/*/.git") + # reject paths that lie inside another castle, like git submodules + return dirs.reject do |dir| + dirs.any? {|other| dir != other && dir.fnmatch(other.parent.join('*').to_s) } + end + end + def inside_each_castle(&block) - Pathname.glob("#{repos_dir}/**/*/.git") do |git_dir| + all_castles.each do |git_dir| castle = git_dir.dirname Dir.chdir castle do # so we can call git config from the right contxt yield castle