Commit afd42d75 authored by Joshua Kalpin's avatar Joshua Kalpin

[SourcesManager] Ignore repos with unreachable sources on update

parent 9f03ab97
......@@ -145,7 +145,7 @@ module Pod
raise Informative, "The `#{source_name}` repo is not a git repo." unless git_repo?(specified_source.repo)
sources = [specified_source]
else
sources = aggregate.all.select { |source| git_repo?(source.repo) }
sources = aggregate.all.select { |source| git_repo?(source.repo) && git_remote_reachable?(source.repo) }
end
sources.each do |source|
......@@ -159,12 +159,24 @@ module Pod
end
end
# Returns whether a git repo's remote is reachable.
#
# @param [Pathname] dir
# The directory where the source is stored.
#
# @return [Bool] Whether the given source's remote is reachable.
#
def git_remote_reachable?(dir)
Dir.chdir(dir) { `git ls-remote` }
$?.exitstatus.zero?
end
# Returns whether a source is a GIT repo.
#
# @param [Pathname] dir
# The directory where the source is stored.
#
# @return [Bool] Wether the given source is a GIT repo.
# @return [Bool] Whether the given source is a GIT repo.
#
def git_repo?(dir)
Dir.chdir(dir) { `git rev-parse >/dev/null 2>&1` }
......
......@@ -95,6 +95,11 @@ module Pod
UI.output.should.match /Already up-to-date/
end
it 'returns whether a source has a reachable git remote' do
SourcesManager.git_remote_reachable?(repo_make('a_new_repo_that_is_new')).should.be.false
SourcesManager.git_remote_reachable?(SourcesManager.master_repo_dir).should.be.true
end
it "returns whether a source is backed by a git repo" do
SourcesManager.git_repo?(SourcesManager.master_repo_dir).should.be.true
SourcesManager.git_repo?(Pathname.new('/tmp')).should.be.false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment