Commit 59a6713a authored by Samuel E. Giddins's avatar Samuel E. Giddins

[Resolver] Fix handling of pre-release specs

This was tough to do, since it really adversely affected performance on unresolvable podfiles. Hence the optimization of making sure that a pod's dependencies with the same root name are pinned to the same version in `dependencies_for`

\c @kylef, @alloy
parent 7da4cad9
...@@ -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: 94dcc7dd1ee1fa0bbce7687c9dd264fb8c91555d revision: 960711c454635d517101757dbf1c337164d6ba6c
branch: resolver branch: resolver
specs: specs:
cocoapods-core (0.34.4) cocoapods-core (0.34.4)
...@@ -18,7 +18,7 @@ GIT ...@@ -18,7 +18,7 @@ GIT
GIT GIT
remote: https://github.com/CocoaPods/Resolver.git remote: https://github.com/CocoaPods/Resolver.git
revision: 8f5241546ce3f67756d87547154b88445b306933 revision: baebceabbbeea954ca3a398794c2008aa72b9d87
branch: master branch: master
specs: specs:
resolver (0.0.1) resolver (0.0.1)
......
...@@ -100,18 +100,23 @@ module Pod ...@@ -100,18 +100,23 @@ module Pod
@search[dependency] ||= begin @search[dependency] ||= begin
find_cached_set(dependency). find_cached_set(dependency).
all_specifications. all_specifications.
select { |s| dependency.requirement.satisfied_by? Version.new(s.version) }. select { |s| dependency.requirement.satisfied_by? s.version }.
reject { |s| !dependency.prerelease? && s.version.prerelease? }.
reverse.
map { |s| s.subspec_by_name dependency.name rescue nil }. map { |s| s.subspec_by_name dependency.name rescue nil }.
compact. compact.
reverse.
each { |s| s.version.head = dependency.head? } each { |s| s.version.head = dependency.head? }
end end
@search[dependency].dup @search[dependency].dup
end end
def dependencies_for(dependency) def dependencies_for(specification)
dependency.all_dependencies specification.all_dependencies.map do |dependency|
if dependency.root_name == Specification.root_name(specification.name)
Dependency.new(dependency.name, specification.version)
else
dependency
end
end
end end
def name_for(dependency) def name_for(dependency)
...@@ -123,15 +128,16 @@ module Pod ...@@ -123,15 +128,16 @@ module Pod
end end
def requirement_satisfied_by?(requirement, activated, spec) def requirement_satisfied_by?(requirement, activated, spec)
existing = activated.vertices.values.map(&:payload).compact.find do |s| existing_vertices = activated.vertices.values.select do |v|
Specification.root_name(s.name) == Specification.root_name(requirement.name) Specification.root_name(v.name) == requirement.root_name
end end
if existing requirement_satisfied = if existing = existing_vertices.map(&:payload).compact.first
existing.version == spec.version && existing.version == spec.version &&
requirement.requirement.satisfied_by?(spec.version) requirement.requirement.satisfied_by?(spec.version)
else else
requirement.requirement.satisfied_by? spec.version requirement.requirement.satisfied_by? spec.version
end end
requirement_satisfied && !(spec.version.prerelease? && existing_vertices.flat_map(&:requirements).none?(&:prerelease?))
end end
# Sort dependencies so that the ones that are easiest to resolve are first. # Sort dependencies so that the ones that are easiest to resolve are first.
...@@ -146,6 +152,7 @@ module Pod ...@@ -146,6 +152,7 @@ module Pod
name = name_for(dependency) name = name_for(dependency)
[ [
activated.vertex_named(name).payload ? 0 : 1, activated.vertex_named(name).payload ? 0 : 1,
dependency.prerelease? ? 0 : 1,
conflicts[name] ? 0 : 1, conflicts[name] ? 0 : 1,
search_for(dependency).count, search_for(dependency).count,
] ]
......
...@@ -157,6 +157,24 @@ module Pod ...@@ -157,6 +157,24 @@ module Pod
) )
end end
it 'handles pre-release dependencies with subspecs' do
@podfile = Podfile.new do
platform :ios, '7.0'
pod 'RestKit', '0.20.0-rc1'
end
resolver = Resolver.new(config.sandbox, @podfile, [], SourcesManager.all)
resolver.resolve.values.flatten.map(&:to_s).sort.should == [
'AFNetworking (1.1.0)',
'RestKit (0.20.0-rc1)',
'RestKit/Core (0.20.0-rc1)',
'RestKit/CoreData (0.20.0-rc1)',
'RestKit/Network (0.20.0-rc1)',
'RestKit/ObjectMapping (0.20.0-rc1)',
'RestKit/Support (0.20.0-rc1)',
'SOCKit (1.1)',
]
end
it 'handles correctly subspecs from external sources' do it 'handles correctly subspecs from external sources' do
@podfile = Podfile.new do @podfile = Podfile.new do
platform :ios platform :ios
......
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