Commit 38269a2a authored by Samuel Giddins's avatar Samuel Giddins

[Analyzer] Detect if a source update is needed

parent 242da6b5
...@@ -32,7 +32,7 @@ module Pod ...@@ -32,7 +32,7 @@ module Pod
def run def run
verify_podfile_exists! verify_podfile_exists!
installer = installer_for_config installer = installer_for_config
installer.repo_update = repo_update?(:default => false) installer.repo_update = repo_update?(:default => nil)
installer.update = false installer.update = false
installer.install! installer.install!
end end
......
...@@ -143,12 +143,16 @@ module Pod ...@@ -143,12 +143,16 @@ module Pod
plugin_sources = run_source_provider_hooks plugin_sources = run_source_provider_hooks
analyzer.sources.insert(0, *plugin_sources) analyzer.sources.insert(0, *plugin_sources)
analyzer.pre_analysis_fetching
UI.section 'Updating local specs repositories' do UI.section 'Updating local specs repositories' do
analyzer.update_repositories analyzer.update_repositories
end if repo_update? end if repo_update? || (repo_update.nil? && analyzer.needs_spec_repo_update?)
UI.section 'Analyzing dependencies' do UI.section 'Analyzing dependencies' do
analyze(analyzer) analyzer.update = update
@analysis_result = analyzer.analyze_after_fetch
@aggregate_targets = @analysis_result.targets
validate_build_configurations validate_build_configurations
clean_sandbox clean_sandbox
end end
......
...@@ -47,6 +47,25 @@ module Pod ...@@ -47,6 +47,25 @@ module Pod
@allow_pre_downloads = true @allow_pre_downloads = true
end end
def needs_spec_repo_update?
raise 'Called without @result' unless @result
return true if !lockfile || !@result.podfile_state.unchanged?
resolver = Resolver.new(sandbox, podfile, locked_dependencies, sources)
dependencies = podfile.dependencies.group_by(&:root_name)
lockfile.pod_names.none? do |name|
version = lockfile.version(name)
deps = dependencies[name] || [Dependency.new(name, version)]
deps.all? do |dep|
set = resolver.send(:find_cached_set, dep)
return true unless spec_file = set.specification_paths_for_version(version).first
return true unless spec = Specification.from_file(spec_file)
spec.checksum == lockfile.checksum(name)
end
end
rescue
true
end
# Performs the analysis. # Performs the analysis.
# #
# The Podfile and the Lockfile provide the information necessary to # The Podfile and the Lockfile provide the information necessary to
...@@ -59,6 +78,12 @@ module Pod ...@@ -59,6 +78,12 @@ module Pod
# @return [AnalysisResult] # @return [AnalysisResult]
# #
def analyze(allow_fetches = true) def analyze(allow_fetches = true)
pre_analysis_fetching(allow_fetches)
analyze_after_fetch
end
def pre_analysis_fetching(allow_fetches = true)
validate_podfile! validate_podfile!
validate_lockfile_version! validate_lockfile_version!
@result = AnalysisResult.new @result = AnalysisResult.new
...@@ -71,7 +96,9 @@ module Pod ...@@ -71,7 +96,9 @@ module Pod
store_existing_checkout_options store_existing_checkout_options
fetch_external_sources if allow_fetches fetch_external_sources if allow_fetches
end
def analyze_after_fetch
@locked_dependencies = generate_version_locking_dependencies @locked_dependencies = generate_version_locking_dependencies
@result.specs_by_target = validate_platforms(resolve_dependencies) @result.specs_by_target = validate_platforms(resolve_dependencies)
@result.specifications = generate_specifications @result.specifications = generate_specifications
......
...@@ -78,6 +78,10 @@ module Pod ...@@ -78,6 +78,10 @@ module Pod
def add_name(name, state) def add_name(name, state)
send(state) << Specification.root_name(name) send(state) << Specification.root_name(name)
end end
def unchanged?
[added, deleted, changed].all?(&:empty?)
end
end end
end end
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