Commit 06bab6d9 authored by Samuel E. Giddins's avatar Samuel E. Giddins

[Analyzer] Use specific checkout options from lockfile

parent 9ca5e278
GIT GIT
remote: https://github.com/CocoaPods/Core.git remote: https://github.com/CocoaPods/Core.git
revision: 60a486e8141323390dc5ff7f6676cf893a251a48 revision: 854ff482bc9d41b1acebbaae2fc6c67204a08d0f
branch: master branch: lockfile-checkout-options
specs: specs:
cocoapods-core (0.35.0.rc2) cocoapods-core (0.35.0.rc2)
activesupport (>= 3.2.15) activesupport (>= 3.2.15)
......
...@@ -13,9 +13,11 @@ module Pod ...@@ -13,9 +13,11 @@ module Pod
# hash. # hash.
# #
def self.from_dependency(dependency, podfile_path) def self.from_dependency(dependency, podfile_path)
name = dependency.root_name from_params(dependency.external_source, dependency, podfile_path)
params = dependency.external_source end
def self.from_params(params, dependency, podfile_path)
name = dependency.root_name
if klass = concrete_class_from_params(params) if klass = concrete_class_from_params(params)
klass.new(name, params, podfile_path) klass.new(name, params, podfile_path)
else else
......
...@@ -466,7 +466,7 @@ module Pod ...@@ -466,7 +466,7 @@ module Pod
# #
def write_lockfiles def write_lockfiles
# checkout_options = sandbox.checkout_options # checkout_options = sandbox.checkout_options
@lockfile = Lockfile.generate(podfile, analysis_result.specifications) @lockfile = Lockfile.generate(podfile, analysis_result.specifications, sandbox.checkout_sources)
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)
......
...@@ -264,34 +264,55 @@ module Pod ...@@ -264,34 +264,55 @@ module Pod
# #
def fetch_external_sources def fetch_external_sources
return unless allow_pre_downloads? return unless allow_pre_downloads?
deps_to_fetch = []
deps_to_fetch_if_needed = []
deps_with_external_source = podfile.dependencies.select(&:external_source)
deps_with_different_sources = podfile.dependencies.group_by(&:root_name).select { |_root_name, dependencies| dependencies.map(&:external_source).uniq.count > 1 } deps_with_different_sources = podfile.dependencies.group_by(&:root_name).select { |_root_name, dependencies| dependencies.map(&:external_source).uniq.count > 1 }
deps_with_different_sources.each do |root_name, dependencies| deps_with_different_sources.each do |root_name, dependencies|
raise Informative, "There are multiple dependencies with different sources for `#{root_name}` in #{UI.path podfile.defined_in_file}:\n\n- #{dependencies.map(&:to_s).join("\n- ")}" raise Informative, "There are multiple dependencies with different sources for `#{root_name}` in #{UI.path podfile.defined_in_file}:\n\n- #{dependencies.map(&:to_s).join("\n- ")}"
end end
if update_mode == :all unless dependencies_to_fetch.empty?
deps_to_fetch = deps_with_external_source UI.section 'Fetching external sources' do
dependencies_to_fetch.sort.each do |dependency|
fetch_external_source(dependency, !pods_to_fetch.include?(dependency.name))
end
end
end
end
def fetch_external_source(dependency, use_lockfile_options)
checkout_options = lockfile.checkout_options_for_pod_named(dependency.root_name) if lockfile
if checkout_options && use_lockfile_options
source = ExternalSources.from_params(checkout_options, dependency, podfile.defined_in_file)
else else
pods_to_fetch = result.podfile_state.added + result.podfile_state.changed source = ExternalSources.from_dependency(dependency, podfile.defined_in_file)
if update_mode == :selected end
pods_to_fetch += update[:pods] source.fetch(sandbox)
end
def dependencies_to_fetch
@deps_to_fetch ||= begin
deps_to_fetch = []
deps_to_fetch_if_needed = []
deps_with_external_source = podfile.dependencies.select(&:external_source)
if update_mode == :all
deps_to_fetch = deps_with_external_source
else
deps_to_fetch = deps_with_external_source.select { |dep| pods_to_fetch.include?(dep.name) }
deps_to_fetch_if_needed = deps_with_external_source.select { |dep| result.podfile_state.unchanged.include?(dep.name) }
deps_to_fetch += deps_to_fetch_if_needed.select { |dep| sandbox.specification(dep.name).nil? || !dep.external_source[:local].nil? || !dep.external_source[:path].nil? || !sandbox.pod_dir(dep.name).directory? }
end end
deps_to_fetch = deps_with_external_source.select { |dep| pods_to_fetch.include?(dep.name) } deps_to_fetch.uniq(&:root_name)
deps_to_fetch_if_needed = deps_with_external_source.select { |dep| result.podfile_state.unchanged.include?(dep.name) }
deps_to_fetch += deps_to_fetch_if_needed.select { |dep| sandbox.specification(dep.name).nil? || !dep.external_source[:local].nil? || !dep.external_source[:path].nil? || !sandbox.pod_dir(dep.name).directory? }
end end
end
unless deps_to_fetch.empty? def pods_to_fetch
UI.section 'Fetching external sources' do @pods_to_fetch ||= begin
deps_to_fetch.uniq(&:root_name).sort.each do |dependency| pods_to_fetch = result.podfile_state.added + result.podfile_state.changed
source = ExternalSources.from_dependency(dependency, podfile.defined_in_file) if update_mode == :selected
source.fetch(sandbox) pods_to_fetch += update[:pods]
end
end end
pods_to_fetch
end end
end end
......
...@@ -63,7 +63,8 @@ module Pod ...@@ -63,7 +63,8 @@ module Pod
s.version = '1.0' s.version = '1.0'
end, end,
] ]
Lockfile.generate(podfile, specs).write_to_disk(temporary_directory + 'Podfile.lock') external_sources = {}
Lockfile.generate(podfile, specs, external_sources).write_to_disk(temporary_directory + 'Podfile.lock')
end end
it 'for a single missing Pod' do it 'for a single missing Pod' do
......
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