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