Commit 52bd3990 authored by Samuel E. Giddins's avatar Samuel E. Giddins

Merge branch 'resolver-all-sources'

parents 77f29854 2571e819
...@@ -60,6 +60,11 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides ...@@ -60,6 +60,11 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
[Kyle Fuller](https://github.com/kylef) [Kyle Fuller](https://github.com/kylef)
[#2591](https://github.com/CocoaPods/CocoaPods/issues/2591) [#2591](https://github.com/CocoaPods/CocoaPods/issues/2591)
* Take into account versions of a Pod from all specified sources when
resolving dependencies.
[Thomas Visser](https://github.com/Thomvis)
[#2556](https://github.com/CocoaPods/CocoaPods/issues/2556)
## 0.34.1 ## 0.34.1
......
...@@ -7,7 +7,7 @@ GIT ...@@ -7,7 +7,7 @@ GIT
GIT GIT
remote: https://github.com/CocoaPods/Core.git remote: https://github.com/CocoaPods/Core.git
revision: 159d93cb7576523efaf9856d069f5df23b29e646 revision: 10d6dc5a3615e738cd682fd05d3f658db8e53d73
branch: master branch: master
specs: specs:
cocoapods-core (0.34.1) cocoapods-core (0.34.1)
......
...@@ -150,6 +150,11 @@ module Pod ...@@ -150,6 +150,11 @@ module Pod
set = find_cached_set(dependency, dependent_spec) set = find_cached_set(dependency, dependent_spec)
set.required_by(dependency, dependent_spec.to_s) set.required_by(dependency, dependent_spec.to_s)
if (paths = set.specification_paths_for_version(set.required_version)).length > 1
UI.warn "Found multiple specifications for #{dependency}:\n" \
"- #{paths.join("\n")}"
end
unless @loaded_specs.include?(dependency.name) unless @loaded_specs.include?(dependency.name)
spec = set.specification.subspec_by_name(dependency.name) spec = set.specification.subspec_by_name(dependency.name)
@loaded_specs << spec.name @loaded_specs << spec.name
...@@ -190,7 +195,7 @@ module Pod ...@@ -190,7 +195,7 @@ module Pod
end end
set = Specification::Set::External.new(spec) set = Specification::Set::External.new(spec)
else else
set = find_set_from_sources(dependency) set = create_set_from_sources(dependency)
end end
cached_sets[name] = set cached_sets[name] = set
unless set unless set
...@@ -201,19 +206,21 @@ module Pod ...@@ -201,19 +206,21 @@ module Pod
cached_sets[name] cached_sets[name]
end end
# @return [Set] Loads a set for the Pod of the given dependency from the # @return [Set] Creates a set for the Pod of the given dependency from the
# sources. The set will be limited to the versions of the first # sources. The set will contain all versions from all sources that
# source which includes the Pod. # include the Pod.
# #
# @param [Dependency] dependency # @param [Dependency] dependency
# The dependency for which the set is needed. # The dependency for which the set is needed.
# #
def find_set_from_sources(dependency) def create_set_from_sources(dependency)
sources.each do |source| aggregate.search(dependency)
set = source.search(dependency) end
return set if set
end # @return [Source::Aggregate] The aggregate of the {#sources}.
nil #
def aggregate
@aggregate ||= Source::Aggregate.new(sources.map(&:repo))
end end
# Ensures that a specification is compatible with the platform of a target. # Ensures that a specification is compatible with the platform of a target.
......
...@@ -234,20 +234,44 @@ COCOAPODS: 0.33.1 ...@@ -234,20 +234,44 @@ COCOAPODS: 0.33.1
version.to_s.should == '2.5.1' version.to_s.should == '2.5.1'
end end
it 'takes into account the order of the sources' do it 'consults all sources when finding a matching spec' do
podfile = Podfile.new do podfile = Podfile.new do
platform :ios platform :ios
pod 'JSONKit' pod 'JSONKit', '> 2'
end end
file = fixture('spec-repos/test_repo/JSONKit/999.999.999/JSONKit.podspec')
sources = SourcesManager.sources(%w(master test_repo)) sources = SourcesManager.sources(%w(master test_repo))
resolver = Resolver.new(config.sandbox, podfile, [], sources) resolver = Resolver.new(config.sandbox, podfile, [], sources)
version = resolver.resolve.values.flatten.first.version spec = resolver.resolve.values.flatten.first
version.to_s.should.not == '999.999.999' spec.version.to_s.should == '999.999.999'
spec.defined_in_file.should == file
sources = SourcesManager.sources(%w(test_repo master)) sources = SourcesManager.sources(%w(test_repo master))
resolver = Resolver.new(config.sandbox, podfile, [], sources) resolver = Resolver.new(config.sandbox, podfile, [], sources)
version = resolver.resolve.values.flatten.first.version spec = resolver.resolve.values.flatten.first
version.to_s.should == '999.999.999' spec.version.to_s.should == '999.999.999'
resolver.resolve.values.flatten.first.defined_in_file.should == file
end
it 'warns and chooses the first source when multiple sources contain ' \
'a pod' do
podfile = Podfile.new do
platform :ios
pod 'JSONKit', '1.4'
end
sources = SourcesManager.sources(%w(master test_repo))
resolver = Resolver.new(config.sandbox, podfile, [], sources)
spec = resolver.resolve.values.flatten.first
spec.version.to_s.should == '1.4'
spec.defined_in_file.should == fixture('spec-repos/master/Specs/JSONKit/1.4/JSONKit.podspec.json')
sources = SourcesManager.sources(%w(test_repo master))
resolver = Resolver.new(config.sandbox, podfile, [], sources)
spec = resolver.resolve.values.flatten.first
spec.version.to_s.should == '1.4'
resolver.resolve.values.flatten.first.defined_in_file.should == fixture('spec-repos/test_repo/JSONKit/1.4/JSONKit.podspec')
UI.warnings.should.match /multiple specifications/
end end
end end
......
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