Commit 2e6a2c9e authored by Samuel E. Giddins's avatar Samuel E. Giddins

[Analyzer] Ensure that the right checkout options are used when a downlaod of…

[Analyzer] Ensure that the right checkout options are used when a downlaod of the Pod already exists
parent 06bab6d9
...@@ -265,11 +265,7 @@ module Pod ...@@ -265,11 +265,7 @@ module Pod
def fetch_external_sources def fetch_external_sources
return unless allow_pre_downloads? return unless allow_pre_downloads?
deps_with_different_sources = podfile.dependencies.group_by(&:root_name).select { |_root_name, dependencies| dependencies.map(&:external_source).uniq.count > 1 } verify_no_pods_with_different_sources!
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- ")}"
end
unless dependencies_to_fetch.empty? unless dependencies_to_fetch.empty?
UI.section 'Fetching external sources' do UI.section 'Fetching external sources' do
dependencies_to_fetch.sort.each do |dependency| dependencies_to_fetch.sort.each do |dependency|
...@@ -279,6 +275,16 @@ module Pod ...@@ -279,6 +275,16 @@ module Pod
end end
end end
def verify_no_pods_with_different_sources!
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|
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
def fetch_external_source(dependency, use_lockfile_options) def fetch_external_source(dependency, use_lockfile_options)
checkout_options = lockfile.checkout_options_for_pod_named(dependency.root_name) if lockfile checkout_options = lockfile.checkout_options_for_pod_named(dependency.root_name) if lockfile
if checkout_options && use_lockfile_options if checkout_options && use_lockfile_options
...@@ -300,12 +306,25 @@ module Pod ...@@ -300,12 +306,25 @@ module Pod
else else
deps_to_fetch = deps_with_external_source.select { |dep| pods_to_fetch.include?(dep.name) } 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_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? } deps_to_fetch += deps_to_fetch_if_needed.select do |dep|
sandbox.specification(dep.name).nil? ||
!dep.external_source[:local].nil? ||
!dep.external_source[:path].nil? ||
!sandbox.pod_dir(dep.root_name).directory? ||
checkout_requires_update?(dep)
end
end end
deps_to_fetch.uniq(&:root_name) deps_to_fetch.uniq(&:root_name)
end end
end end
def checkout_requires_update?(dependency)
return true unless lockfile && sandbox.manifest
locked_checkout_options = lockfile.checkout_options_for_pod_named(dependency.root_name)
sandbox_checkout_options = sandbox.manifest.checkout_options_for_pod_named(dependency.root_name)
locked_checkout_options != sandbox_checkout_options
end
def pods_to_fetch def pods_to_fetch
@pods_to_fetch ||= begin @pods_to_fetch ||= begin
pods_to_fetch = result.podfile_state.added + result.podfile_state.changed pods_to_fetch = result.podfile_state.added + result.podfile_state.changed
......
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