Commit d534af61 authored by Eric Amorde's avatar Eric Amorde

Do not force include master spec repo if plugin sources are provided

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