Commit 7847c54b authored by Samuel Giddins's avatar Samuel Giddins

Store spec repos in the Lockfile

parent df6872de
......@@ -20,6 +20,9 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
existing specs that have already been pushed.
[Samuel Giddins](https://github.com/segiddins)
* Store which specs repo a pod comes from in the lockfile.
[Samuel Giddins](https://github.com/segiddins)
##### Bug Fixes
* Unique all available pre-release versions when displaying
......
......@@ -25,7 +25,7 @@ gem 'json', :git => 'https://github.com/segiddins/json.git', :branch => 'seg-1.7
group :development do
cp_gem 'claide', 'CLAide'
cp_gem 'cocoapods-core', 'Core'
cp_gem 'cocoapods-core', 'Core', 'seg-lockfile-spec-repos'
cp_gem 'cocoapods-deintegrate', 'cocoapods-deintegrate'
cp_gem 'cocoapods-downloader', 'cocoapods-downloader'
cp_gem 'cocoapods-plugins', 'cocoapods-plugins'
......
......@@ -7,8 +7,8 @@ GIT
GIT
remote: https://github.com/CocoaPods/Core.git
revision: b4fb2f193897c789c094d126ebca91034edc261d
branch: master
revision: f80744433c6d5d1229d663b289456cc5662d91a9
branch: seg-lockfile-spec-repos
specs:
cocoapods-core (1.4.0)
activesupport (>= 4.0.2, < 6)
......@@ -180,7 +180,7 @@ GEM
gh_inspector (1.0.3)
git (1.3.0)
hashdiff (0.3.1)
i18n (0.9.1)
i18n (0.9.3)
concurrent-ruby (~> 1.0)
inch (0.7.0)
pry
......
......@@ -550,7 +550,7 @@ module Pod
def write_lockfiles
external_source_pods = podfile.dependencies.select(&:external_source).map(&:root_name).uniq
checkout_options = sandbox.checkout_sources.select { |root_name, _| external_source_pods.include? root_name }
@lockfile = Lockfile.generate(podfile, analysis_result.specifications, checkout_options)
@lockfile = Lockfile.generate(podfile, analysis_result.specifications, checkout_options, analysis_result.specs_by_source)
UI.message "- Writing Lockfile in #{UI.path config.lockfile_path}" do
@lockfile.write_to_disk(config.lockfile_path)
......
......@@ -90,6 +90,8 @@ module Pod
@result.specs_by_target = resolver_specs_by_target.each_with_object({}) do |rspecs_by_target, hash|
hash[rspecs_by_target[0]] = rspecs_by_target[1].map(&:spec)
end
@result.specs_by_source = Hash[resolver_specs_by_target.values.flatten(1).group_by(&:source).map { |source, specs| [source, specs.map(&:spec).uniq] }]
sources.each { |s| @result.specs_by_source[s] ||= [] }
@result
end
......
......@@ -11,6 +11,11 @@ module Pod
#
attr_accessor :specs_by_target
# @return [Hash{Source => Array<Specification>}] the
# specifications grouped by spec repo source.
#
attr_accessor :specs_by_source
# @return [Array<Specification>] the specifications of the resolved
# version of Pods that should be installed.
#
......
......@@ -20,14 +20,19 @@ module Pod
#
attr_reader :spec
# @return [Source] the spec repo source the specification came from
#
attr_reader :source
# @return [Bool] whether this resolved specification is only used by tests.
#
attr_reader :used_by_tests_only
alias used_by_tests_only? used_by_tests_only
def initialize(spec, used_by_tests_only)
def initialize(spec, used_by_tests_only, source)
@spec = spec
@used_by_tests_only = used_by_tests_only
@source = source
end
def name
......@@ -129,7 +134,7 @@ module Pod
resolver_specs_by_target[target] = specs.
group_by(&:first).
map { |vertex, spec_test_only_tuples| ResolverSpecification.new(vertex.payload, spec_test_only_tuples.map { |tuple| tuple[1] }.all?) }.
map { |vertex, spec_test_only_tuples| ResolverSpecification.new(vertex.payload, spec_test_only_tuples.map { |tuple| tuple[1] }.all?, vertex.payload.respond_to?(:spec_source) && vertex.payload.spec_source) }.
sort_by(&:name)
end
end
......
require 'delegate'
module Pod
class Specification
class Set
class LazySpecification < BasicObject
attr_reader :name, :version, :source
def initialize(name, version, source)
@name = name
@version = version
@source = source
class SpecWithSource < DelegateClass(Specification)
attr_reader :spec_repo
def initialize(spec, source)
super(spec)
@spec_repo = source
end
def method_missing(method, *args, &block)
specification.send(method, *args, &block)
undef is_a?
end
def respond_to_missing?(method, include_all = false)
specification.respond_to?(method, include_all)
class LazySpecification < DelegateClass(Specification)
attr_reader :name, :version, :spec_source
def initialize(name, version, spec_source)
@name = name
@version = version
@spec_source = spec_source
end
def subspec_by_name(name = nil, raise_if_missing = true, include_test_specifications = false)
subspec =
if !name || name == self.name
self
else
specification.subspec_by_name(name, raise_if_missing, include_test_specifications)
end
return unless subspec
SpecWithSource.new subspec, spec_source
end
def specification
@specification ||= source.specification(name, version.version)
@specification ||= spec_source.specification(name, version.version)
end
alias __getobj__ specification
undef is_a?
end
class External
......
......@@ -32,7 +32,7 @@ module Pod
```
#{exception.class} - #{exception.message}
#{exception.backtrace.join("\n")}
#{exception.backtrace.join("\n") if exception.backtrace}
```
#{'――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――'.reversed}
......
Subproject commit 47f6e71c0f9001d2da80686e9b90870ad394e228
Subproject commit 1c0d8e5d3072b520ec2dd6794e8f3c13b508b516
......@@ -30,7 +30,11 @@ module Pod
end,
]
external_sources = {}
Lockfile.generate(podfile, specs, external_sources).write_to_disk(temporary_directory + 'Podfile.lock')
specs_by_source = {
Source.new(fixture('spec-repos/master')) => specs,
}
Lockfile.generate(podfile, specs, external_sources, specs_by_source).
write_to_disk(temporary_directory + 'Podfile.lock')
end
describe 'updates of the spec repos' do
......
......@@ -698,8 +698,8 @@ module Pod
#-------------------------------------------------------------------------#
it 'does include pod target if any spec is not used by tests only and is part of target definition' do
spec1 = Resolver::ResolverSpecification.new(stub, false)
spec2 = Resolver::ResolverSpecification.new(stub, true)
spec1 = Resolver::ResolverSpecification.new(stub, false, nil)
spec2 = Resolver::ResolverSpecification.new(stub, true, nil)
target_definition = stub
pod_target = stub(:name => 'Pod1', :target_definitions => [target_definition], :specs => [spec1.spec, spec2.spec])
resolver_specs_by_target = { target_definition => [spec1, spec2] }
......@@ -707,8 +707,8 @@ module Pod
end
it 'does not include pod target if its used by tests only' do
spec1 = Resolver::ResolverSpecification.new(stub, true)
spec2 = Resolver::ResolverSpecification.new(stub, true)
spec1 = Resolver::ResolverSpecification.new(stub, true, nil)
spec2 = Resolver::ResolverSpecification.new(stub, true, nil)
target_definition = stub
pod_target = stub(:name => 'Pod1', :target_definitions => [target_definition], :specs => [spec1.spec, spec2.spec])
resolver_specs_by_target = { target_definition => [spec1, spec2] }
......@@ -716,7 +716,7 @@ module Pod
end
it 'does not include pod target if its not part of the target definition' do
spec = Resolver::ResolverSpecification.new(stub, false)
spec = Resolver::ResolverSpecification.new(stub, false, nil)
target_definition = stub
pod_target = stub(:name => 'Pod1', :target_definitions => [], :specs => [spec.spec])
resolver_specs_by_target = { target_definition => [spec] }
......
......@@ -564,6 +564,7 @@ module Pod
before do
@analysis_result = Installer::Analyzer::AnalysisResult.new
@analysis_result.specifications = [fixture_spec('banana-lib/BananaLib.podspec')]
@analysis_result.specs_by_source = {}
@installer.stubs(:analysis_result).returns(@analysis_result)
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