Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SourcesManager] Ignore repos with unreachable sources on update #1595

Merged
merged 4 commits into from Nov 16, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Expand Up @@ -12,6 +12,13 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
[Kevin Wales](https://github.com/kwales) [Kevin Wales](https://github.com/kwales)
[#1562](https://github.com/CocoaPods/pull/1562) [#1562](https://github.com/CocoaPods/pull/1562)


* When updating the pod repos, repositories with unreachable remotes
are now ignored. This fixes an issue with certain private repositories.
[Joshua Kalpin](https://github.com/Kapin)
[#1595](https://github.com/CocoaPods/CocoaPods/pull/1595)
[#1571](https://github.com/CocoaPods/CocoaPods/issues/1571)


## 0.28.0 ## 0.28.0
[CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.27.1...0.28.0) [CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.27.1...0.28.0)
• [CocoaPods-core](https://github.com/CocoaPods/Core/compare/0.27.1...0.28.0) • [CocoaPods-core](https://github.com/CocoaPods/Core/compare/0.27.1...0.28.0)
Expand Down
20 changes: 16 additions & 4 deletions lib/cocoapods/sources_manager.rb
Expand Up @@ -145,7 +145,7 @@ def update(source_name = nil, show_output = false)
raise Informative, "The `#{source_name}` repo is not a git repo." unless git_repo?(specified_source.repo) raise Informative, "The `#{source_name}` repo is not a git repo." unless git_repo?(specified_source.repo)
sources = [specified_source] sources = [specified_source]
else 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 end


sources.each do |source| sources.each do |source|
Expand All @@ -159,16 +159,28 @@ def update(source_name = nil, show_output = false)
end end
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') }
$?.success?
end

# Returns whether a source is a GIT repo. # Returns whether a source is a GIT repo.
# #
# @param [Pathname] dir # @param [Pathname] dir
# The directory where the source is stored. # 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) def git_repo?(dir)
Dir.chdir(dir) { `git rev-parse >/dev/null 2>&1` } Dir.chdir(dir) { git('rev-parse >/dev/null 2>&1') }
$?.exitstatus.zero? $?.success?
end end


# Checks the version information of the source with the given directory. # Checks the version information of the source with the given directory.
Expand Down
5 changes: 5 additions & 0 deletions spec/unit/sources_manager_spec.rb
Expand Up @@ -95,6 +95,11 @@ module Pod
UI.output.should.match /Already up-to-date/ UI.output.should.match /Already up-to-date/
end 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 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?(SourcesManager.master_repo_dir).should.be.true
SourcesManager.git_repo?(Pathname.new('/tmp')).should.be.false SourcesManager.git_repo?(Pathname.new('/tmp')).should.be.false
Expand Down