Commit 0fcf5944 authored by Dimitris Koutsogiorgas's avatar Dimitris Koutsogiorgas Committed by GitHub

Merge pull request #7033 from amorde/cocoapods-5306

Do not force include master spec repo if plugin sources are provided
parents 7395fa95 d534af61
......@@ -8,6 +8,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Enhancements
* Do not force include the master spec repo if plugins provide sources
[Eric Amorde](https://github.com/amorde)
[#7033](https://github.com/CocoaPods/CocoaPods/pull/7033)
* Add custom shell script integration from Podfile
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#6820](https://github.com/CocoaPods/CocoaPods/pull/6820)
......
......@@ -140,11 +140,11 @@ module Pod
end
end
# @return [Analyzer] The analyzer used to resolve dependencies
#
def resolve_dependencies
analyzer = create_analyzer
plugin_sources = run_source_provider_hooks
analyzer.sources.insert(0, *plugin_sources)
analyzer = create_analyzer(plugin_sources)
UI.section 'Updating local specs repositories' do
analyzer.update_repositories
......@@ -155,6 +155,7 @@ module Pod
validate_build_configurations
clean_sandbox
end
analyzer
end
def download_dependencies
......@@ -243,8 +244,8 @@ module Pod
@aggregate_targets = analyzer.result.targets
end
def create_analyzer
Analyzer.new(sandbox, podfile, lockfile).tap do |analyzer|
def create_analyzer(plugin_sources = nil)
Analyzer.new(sandbox, podfile, lockfile, plugin_sources).tap do |analyzer|
analyzer.installation_options = installation_options
analyzer.has_dependencies = has_dependencies?
end
......
......@@ -32,16 +32,22 @@ module Pod
#
attr_reader :lockfile
# @return [Array<Source>] Sources provided by plugins
#
attr_reader :plugin_sources
# Initialize a new instance
#
# @param [Sandbox] sandbox @see sandbox
# @param [Podfile] podfile @see podfile
# @param [Lockfile] lockfile @see lockfile
# @param [Sandbox] sandbox @see sandbox
# @param [Podfile] podfile @see podfile
# @param [Lockfile] lockfile @see lockfile
# @param [Array<Source>] plugin_sources @see plugin_sources
#
def initialize(sandbox, podfile, lockfile = nil)
def initialize(sandbox, podfile, lockfile = nil, plugin_sources = nil)
@sandbox = sandbox
@podfile = podfile
@lockfile = lockfile
@plugin_sources = plugin_sources
@update = false
@allow_pre_downloads = true
......@@ -825,8 +831,8 @@ module Pod
# Returns the sources used to query for specifications
#
# When no explicit Podfile sources are defined, this defaults to the
# master spec repository.
# When no explicit Podfile sources or plugin sources are defined, this
# defaults to the master spec repository.
# available sources ({config.sources_manager.all}).
#
# @return [Array<Source>] the sources to be used in finding
......@@ -835,6 +841,7 @@ module Pod
def sources
@sources ||= begin
sources = podfile.sources
plugin_sources = @plugin_sources || []
# Add any sources specified using the :source flag on individual dependencies.
dependency_sources = podfile.dependencies.map(&:podspec_repo).compact
......@@ -842,15 +849,19 @@ module Pod
if all_dependencies_have_sources
sources = dependency_sources
elsif has_dependencies? && sources.empty?
elsif has_dependencies? && sources.empty? && plugin_sources.empty?
sources = ['https://github.com/CocoaPods/Specs.git']
else
sources += dependency_sources
end
sources.uniq.map do |source_url|
result = sources.uniq.map do |source_url|
config.sources_manager.find_or_create_source_with_url(source_url)
end
unless plugin_sources.empty?
result.insert(0, *plugin_sources)
end
result
end
end
......
......@@ -103,46 +103,71 @@ module Pod
@installer.install!
end
it 'runs source provider hooks before analyzing' do
@installer.unstub(:resolve_dependencies)
@installer.stubs(:validate_build_configurations)
@installer.stubs(:clean_sandbox)
def @installer.run_source_provider_hooks
@hook_called = true
describe 'handling spec sources' do
before do
@hooks_manager = Pod::HooksManager
@hooks_manager.instance_variable_set(:@registrations, nil)
end
def @installer.analyze(*)
it 'runs source provider hooks before analyzing' do
@installer.unstub(:resolve_dependencies)
@installer.stubs(:validate_build_configurations)
@installer.stubs(:clean_sandbox)
@installer.stubs(:analyze)
@installer.stubs(:run_source_provider_hooks).with do
@hook_called = true
end
@installer.install!
@hook_called.should.be.true
end
@installer.install!
end
it 'includes sources from source provider plugins' do
plugin_name = 'test-plugin'
Pod::HooksManager.register(plugin_name, :source_provider) do |context, options|
source_url = options['sources'].first
return unless source_url
source = Pod::Source.new(source_url)
context.add_source(source)
end
it 'includes sources from source provider plugins' do
plugin_name = 'test-plugin'
@hooks_manager.register(plugin_name, :source_provider) do |context, options|
source_url = options['sources'].first
return unless source_url
source = Pod::Source.new(source_url)
context.add_source(source)
end
test_source_name = 'https://github.com/artsy/Specs.git'
plugins_hash = Installer::DEFAULT_PLUGINS.merge(plugin_name => { 'sources' => [test_source_name] })
@installer.podfile.stubs(:plugins).returns(plugins_hash)
@installer.unstub(:resolve_dependencies)
@installer.stubs(:validate_build_configurations)
@installer.stubs(:clean_sandbox)
@installer.stubs(:ensure_plugins_are_installed!)
@installer.stubs(:analyze)
test_source_name = 'https://github.com/artsy/CustomSpecs.git'
plugins_hash = Installer::DEFAULT_PLUGINS.merge(plugin_name => { 'sources' => [test_source_name] })
@installer.podfile.stubs(:plugins).returns(plugins_hash)
@installer.unstub(:resolve_dependencies)
@installer.stubs(:validate_build_configurations)
@installer.stubs(:clean_sandbox)
@installer.stubs(:analyze)
Installer::Analyzer.any_instance.stubs(:update_repositories)
analyzer = @installer.resolve_dependencies
source = Pod::Source.new(test_source_name)
names = analyzer.sources.map(&:name)
names.should.include(source.name)
end
it 'does not automatically add master spec repo if plugin sources exist' do
plugin_name = 'test-plugin'
@hooks_manager.register(plugin_name, :source_provider) do |context, options|
source_url = options['sources'].first
return unless source_url
source = Pod::Source.new(source_url)
context.add_source(source)
end
analyzer = Installer::Analyzer.new(config.sandbox, @installer.podfile, @installer.lockfile)
analyzer.stubs(:analyze)
@installer.stubs(:create_analyzer).returns(analyzer)
@installer.install!
test_source_name = 'https://github.com/artsy/CustomSpecs.git'
plugins_hash = Installer::DEFAULT_PLUGINS.merge(plugin_name => { 'sources' => [test_source_name] })
@installer.podfile.stubs(:plugins).returns(plugins_hash)
@installer.unstub(:resolve_dependencies)
@installer.stubs(:validate_build_configurations)
@installer.stubs(:clean_sandbox)
@installer.stubs(:analyze)
Installer::Analyzer.any_instance.stubs(:update_repositories)
source = Pod::Source.new(test_source_name)
names = analyzer.sources.map(&:name)
names.should.include(source.name)
analyzer = @installer.resolve_dependencies
names = analyzer.sources.map(&:name)
names.should == [Pod::Source.new('https://github.com/artsy/CustomSpecs.git').name]
end
end
it 'integrates the user targets if the corresponding config is set' do
......
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