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
GIT
remote: https://github.com/CocoaPods/Core.git
revision: 94dcc7dd1ee1fa0bbce7687c9dd264fb8c91555d
revision: 960711c454635d517101757dbf1c337164d6ba6c
branch: resolver
specs:
cocoapods-core (0.34.4)
......@@ -18,7 +18,7 @@ GIT
GIT
remote: https://github.com/CocoaPods/Resolver.git
revision: 8f5241546ce3f67756d87547154b88445b306933
revision: baebceabbbeea954ca3a398794c2008aa72b9d87
branch: master
specs:
resolver (0.0.1)
......
......@@ -100,18 +100,23 @@ module Pod
@search[dependency] ||= begin
find_cached_set(dependency).
all_specifications.
select { |s| dependency.requirement.satisfied_by? Version.new(s.version) }.
reject { |s| !dependency.prerelease? && s.version.prerelease? }.
reverse.
select { |s| dependency.requirement.satisfied_by? s.version }.
map { |s| s.subspec_by_name dependency.name rescue nil }.
compact.
reverse.
each { |s| s.version.head = dependency.head? }
end
@search[dependency].dup
end
def dependencies_for(dependency)
dependency.all_dependencies
def dependencies_for(specification)
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
def name_for(dependency)
......@@ -123,15 +128,16 @@ module Pod
end
def requirement_satisfied_by?(requirement, activated, spec)
existing = activated.vertices.values.map(&:payload).compact.find do |s|
Specification.root_name(s.name) == Specification.root_name(requirement.name)
existing_vertices = activated.vertices.values.select do |v|
Specification.root_name(v.name) == requirement.root_name
end
if existing
existing.version == spec.version &&
requirement.requirement.satisfied_by?(spec.version)
requirement_satisfied = if existing = existing_vertices.map(&:payload).compact.first
existing.version == spec.version &&
requirement.requirement.satisfied_by?(spec.version)
else
requirement.requirement.satisfied_by? spec.version
end
requirement_satisfied && !(spec.version.prerelease? && existing_vertices.flat_map(&:requirements).none?(&:prerelease?))
end
# Sort dependencies so that the ones that are easiest to resolve are first.
......@@ -146,6 +152,7 @@ module Pod
name = name_for(dependency)
[
activated.vertex_named(name).payload ? 0 : 1,
dependency.prerelease? ? 0 : 1,
conflicts[name] ? 0 : 1,
search_for(dependency).count,
]
......
......@@ -157,6 +157,24 @@ module Pod
)
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
@podfile = Podfile.new do
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