Commit 03c60f3c authored by Samuel E. Giddins's avatar Samuel E. Giddins

Merge pull request #3625 from CocoaPods/seg-update-repos-label

Make updating specs repos its own UI section
parents a59bd1b8 20268749
......@@ -98,7 +98,7 @@ module Pod
def spec_sets
@spec_sets ||= begin
analyzer.send(:update_repositories_if_needed)
analyzer.send(:update_repositories) unless config.skip_repo_update?
aggregate = Source::Aggregate.new(analyzer.sources.map(&:repo))
installed_pods.map do |pod_name|
aggregate.search(Dependency.new(pod_name))
......
......@@ -110,8 +110,14 @@ module Pod
end
def resolve_dependencies
analyzer = create_analyzer
UI.section 'Updating local specs repositories' do
analyzer.update_repositories
end unless config.skip_repo_update?
UI.section 'Analyzing dependencies' do
analyze
analyze(analyzer)
validate_build_configurations
prepare_for_legacy_compatibility
clean_sandbox
......@@ -179,24 +185,16 @@ module Pod
#
# @return [void]
#
# @note The warning about the version of the Lockfile doesn't use the
# `UI.warn` method because it prints the output only at the end
# of the installation. At that time CocoaPods could have crashed.
#
def analyze
if lockfile && lockfile.cocoapods_version > Version.new(VERSION)
STDERR.puts '[!] The version of CocoaPods used to generate ' \
"the lockfile (#{lockfile.cocoapods_version}) is "\
"higher than the version of the current executable (#{VERSION}). " \
'Incompatibility issues may arise.'.yellow
end
analyzer = Analyzer.new(sandbox, podfile, lockfile)
def analyze(analyzer = create_analyzer)
analyzer.update = update
@analysis_result = analyzer.analyze
@aggregate_targets = analyzer.result.targets
end
def create_analyzer
Analyzer.new(sandbox, podfile, lockfile)
end
# Ensures that the white-listed build configurations are known to prevent
# silent typos.
#
......
......@@ -52,7 +52,7 @@ module Pod
# @return [AnalysisResult]
#
def analyze(allow_fetches = true)
update_repositories_if_needed if allow_fetches
validate_lockfile_version!
@result = AnalysisResult.new
compute_target_platforms
@result.podfile_state = generate_podfile_state
......@@ -145,6 +145,19 @@ module Pod
# @!group Analysis steps
# @note The warning about the version of the Lockfile doesn't use the
# `UI.warn` method because it prints the output only at the end
# of the installation. At that time CocoaPods could have crashed.
#
def validate_lockfile_version!
if lockfile && lockfile.cocoapods_version > Version.new(VERSION)
STDERR.puts '[!] The version of CocoaPods used to generate ' \
"the lockfile (#{lockfile.cocoapods_version}) is "\
"higher than the version of the current executable (#{VERSION}). " \
'Incompatibility issues may arise.'.yellow
end
end
# Compares the {Podfile} with the {Lockfile} in order to detect which
# dependencies should be locked.
#
......@@ -174,22 +187,22 @@ module Pod
end
end
public
# Updates the git source repositories unless the config indicates to skip it.
#
def update_repositories_if_needed
unless config.skip_repo_update?
UI.section 'Updating spec repositories' do
sources.each do |source|
if SourcesManager.git_repo?(source.repo)
SourcesManager.update(source.name)
else
UI.message "Skipping `#{source.name}` update because the repository is not a git source repository."
end
end
def update_repositories
sources.each do |source|
if SourcesManager.git_repo?(source.repo)
SourcesManager.update(source.name)
else
UI.message "Skipping `#{source.name}` update because the repository is not a git source repository."
end
end
end
private
# Creates the models that represent the libraries generated by CocoaPods.
#
# @return [Array<Target>] the generated libraries.
......
......@@ -52,23 +52,11 @@ module Pod
#--------------------------------------#
it 'updates the repositories by default' do
config.skip_repo_update = false
SourcesManager.expects(:update).once
@analyzer.analyze
end
it 'does not update unused sources' do
config.skip_repo_update = false
@analyzer.stubs(:sources).returns(SourcesManager.master)
SourcesManager.expects(:update).once.with('master')
@analyzer.analyze
end
it 'does not updates the repositories if config indicates to skip them' do
config.skip_repo_update = true
SourcesManager.expects(:update).never
@analyzer.analyze
@analyzer.update_repositories
end
it 'does not update non-git repositories' do
......@@ -90,7 +78,7 @@ module Pod
SourcesManager.expects(:update).never
analyzer = Pod::Installer::Analyzer.new(config.sandbox, podfile, nil)
analyzer.stubs(:sources).returns([source])
analyzer.analyze
analyzer.update_repositories
UI.output.should.match /Skipping `#{source.name}` update because the repository is not a git source repository./
......
......@@ -223,6 +223,22 @@ module Pod
#-------------------------------------------------------------------------#
describe 'Dependencies Resolution' do
describe 'updating spec repos' do
it 'does not updates the repositories if config indicates to skip them' do
config.skip_repo_update = true
SourcesManager.expects(:update).never
@installer.send(:resolve_dependencies)
end
it 'updates the repositories by default' do
config.skip_repo_update = false
SourcesManager.expects(:update).once
@installer.send(:resolve_dependencies)
end
end
#--------------------------------------#
describe '#analyze' do
it 'prints a warning if the version of the Lockfile is higher than the one of the executable' do
Lockfile.any_instance.stubs(:cocoapods_version).returns(Version.new('999'))
......
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