def git_remotes(base_dir)
git_config = "#{base_dir}/.git/config"
unless File.exists?(git_config)
parent = base_dir.split('/')[0..-2].join('/')
return git_remotes(parent) unless parent.empty?
else
remotes = {}
current_remote = nil
File.read(git_config).split(/\n/).each do |l|
current_remote = $1 if l.match(/\[remote \"([\w\d-]+)\"\]/)
app = (l.match(/url = git@#{heroku.host}:([\w\d-]+)\.git/) || [])[1]
if current_remote && app
remotes[current_remote.downcase] = app
current_remote = nil
end
end
return remotes
end
end