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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user