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
[Kyle Fuller](https://github.com/kylef)
[#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
......
......@@ -7,7 +7,7 @@ GIT
GIT
remote: https://github.com/CocoaPods/Core.git
revision: 159d93cb7576523efaf9856d069f5df23b29e646
revision: 10d6dc5a3615e738cd682fd05d3f658db8e53d73
branch: master
specs:
cocoapods-core (0.34.1)
......
......@@ -150,6 +150,11 @@ module Pod
set = find_cached_set(dependency, dependent_spec)
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)
spec = set.specification.subspec_by_name(dependency.name)
@loaded_specs << spec.name
......@@ -190,7 +195,7 @@ module Pod
end
set = Specification::Set::External.new(spec)
else
set = find_set_from_sources(dependency)
set = create_set_from_sources(dependency)
end
cached_sets[name] = set
unless set
......@@ -201,19 +206,21 @@ module Pod
cached_sets[name]
end
# @return [Set] Loads a set for the Pod of the given dependency from the
# sources. The set will be limited to the versions of the first
# source which includes the Pod.
# @return [Set] Creates a set for the Pod of the given dependency from the
# sources. The set will contain all versions from all sources that
# include the Pod.
#
# @param [Dependency] dependency
# The dependency for which the set is needed.
#
def find_set_from_sources(dependency)
sources.each do |source|
set = source.search(dependency)
return set if set
def create_set_from_sources(dependency)
aggregate.search(dependency)
end
nil
# @return [Source::Aggregate] The aggregate of the {#sources}.
#
def aggregate
@aggregate ||= Source::Aggregate.new(sources.map(&:repo))
end
# Ensures that a specification is compatible with the platform of a target.
......
......@@ -234,20 +234,44 @@ COCOAPODS: 0.33.1
version.to_s.should == '2.5.1'
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
platform :ios
pod 'JSONKit'
pod 'JSONKit', '> 2'
end
file = fixture('spec-repos/test_repo/JSONKit/999.999.999/JSONKit.podspec')
sources = SourcesManager.sources(%w(master test_repo))
resolver = Resolver.new(config.sandbox, podfile, [], sources)
version = resolver.resolve.values.flatten.first.version
version.to_s.should.not == '999.999.999'
spec = resolver.resolve.values.flatten.first
spec.version.to_s.should == '999.999.999'
spec.defined_in_file.should == file
sources = SourcesManager.sources(%w(test_repo master))
resolver = Resolver.new(config.sandbox, podfile, [], sources)
version = resolver.resolve.values.flatten.first.version
version.to_s.should == '999.999.999'
spec = resolver.resolve.values.flatten.first
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
......
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