Skip to content

Commit

Permalink
Merge pull request #9234 from dnkoutso/fix_pod_repo_update_empty_repo
Browse files Browse the repository at this point in the history
Do not crash if the repos dir is not setup.
  • Loading branch information
dnkoutso committed Oct 9, 2019
2 parents 1c257d5 + b0d566b commit d3c7bcd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Expand Up @@ -12,8 +12,9 @@ To install release candidates run `[sudo] gem install cocoapods --pre`

##### Bug Fixes

* None.

* Do not crash if the repos dir is not setup.
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#9216](https://github.com/CocoaPods/CocoaPods/issues/9216)

## 1.8.3 (2019-10-04)

Expand Down
8 changes: 6 additions & 2 deletions lib/cocoapods/sources_manager.rb
Expand Up @@ -113,9 +113,13 @@ def update(source_name = nil, show_output = false)
end

changed_spec_paths = {}
# Ceate the Spec_Lock file if needed and lock it so that concurrent

# Do not perform an update if the repos dir has not been setup yet.
return unless repos_dir.exist?

# Create the Spec_Lock file if needed and lock it so that concurrent
# repo updates do not cause each other to fail
File.open("#{Config.instance.repos_dir}/Spec_Lock", File::CREAT) do |f|
File.open("#{repos_dir}/Spec_Lock", File::CREAT) do |f|
f.flock(File::LOCK_EX)
sources.each do |source|
UI.section "Updating spec repo `#{source.name}`" do
Expand Down
5 changes: 5 additions & 0 deletions spec/unit/sources_manager_spec.rb
Expand Up @@ -210,6 +210,11 @@ module Pod
master.verify_compatibility!
UI.output.should.not.match /CocoaPods 999.0 is available/
end

it 'does not crash if the repos dir does not exist' do
sources_manager = Source::Manager.new(Pathname.new(Dir.tmpdir) + 'CocoaPods/RepoDir/DoesNotExist')
lambda { sources_manager.update }.should.not.raise
end
end
end
end

0 comments on commit d3c7bcd

Please sign in to comment.