Commit 16392d46 authored by Marius Rackwitz's avatar Marius Rackwitz

Expose Installer#repo_update instead Config#skip_repo_update

parent 99d2ecf6
......@@ -30,10 +30,9 @@ module Pod
end
def run
config.skip_repo_update = !repo_update?(:default => false)
verify_podfile_exists!
installer = installer_for_config
installer.repo_update = repo_update?(:default => false)
installer.update = false
installer.install!
end
......
......@@ -45,11 +45,10 @@ module Pod
end
def run
config.skip_repo_update = !repo_update?(:default => true)
verify_podfile_exists!
installer = installer_for_config
installer.repo_update = repo_update?(:default => true)
if @pods
verify_lockfile_exists!
verify_pods_are_installed!
......
......@@ -14,7 +14,6 @@ module Pod
DEFAULTS = {
:verbose => false,
:silent => false,
:skip_repo_update => false,
:skip_download_cache => !ENV['COCOAPODS_SKIP_CACHE'].nil?,
:new_version_message => ENV['COCOAPODS_SKIP_UPDATE_MESSAGE'].nil?,
......@@ -69,11 +68,6 @@ module Pod
# @!group Installation
# @return [Bool] Whether the installer should skip the repos update.
#
attr_accessor :skip_repo_update
alias_method :skip_repo_update?, :skip_repo_update
# @return [Bool] Whether the installer should skip the download cache.
#
attr_accessor :skip_download_cache
......
......@@ -84,6 +84,11 @@ module Pod
#
attr_accessor :update
# @return [Bool] Whether the spec repos should be updated.
#
attr_accessor :repo_update
alias_method :repo_update?, :repo_update
# @return [Boolean] Whether default plugins should be used during
# installation. Defaults to true.
#
......@@ -140,7 +145,7 @@ module Pod
UI.section 'Updating local specs repositories' do
analyzer.update_repositories
end unless config.skip_repo_update?
end if repo_update?
UI.section 'Analyzing dependencies' do
analyze(analyzer)
......
......@@ -349,7 +349,6 @@ module Pod
@original_config = Config.instance.clone
config.installation_root = validation_dir
config.silent = !config.verbose
config.skip_repo_update = true
end
def tear_down_validation_environment
......
......@@ -7,17 +7,24 @@ module Pod
exception.message.should.include "No `Podfile' found in the project directory."
end
it "doesn't update the spec repos by default" do
config.with_changes(:skip_repo_update => nil) do
Pod::Command.parse(['install'])
config.skip_repo_update.should.be.true
describe 'updates of the spec repos' do
before do
file = temporary_directory + 'Podfile'
File.open(file, 'w') do |f|
f.puts('platform :ios')
f.puts('pod "Reachability"')
end
Installer.any_instance.expects(:install!)
end
it "doesn't update the spec repos by default" do
Installer.any_instance.expects(:repo_update=).with(false)
run_command('install')
end
it 'updates the spec repos if that option was given' do
config.with_changes(:skip_repo_update => nil) do
Pod::Command.parse(['install', '--repo-update'])
config.skip_repo_update.should.be.false
Installer.any_instance.expects(:repo_update=).with(true)
run_command('install', '--repo-update')
end
end
end
......
......@@ -6,7 +6,6 @@ module Pod
before do
Command::Outdated.any_instance.stubs(:unlocked_pods).returns([])
config.stubs(:skip_repo_update?).returns(true)
end
it 'tells the user that no Podfile was found in the project dir' do
......@@ -55,7 +54,6 @@ module Pod
pod 'AFNetworking'
end
config.stubs(:podfile).returns(podfile)
config.stubs(:skip_repo_update?).returns(false)
lockfile = mock
lockfile.stubs(:version).returns(Version.new('1.0'))
lockfile.stubs(:pod_names).returns(%w(AFNetworking))
......@@ -69,8 +67,6 @@ module Pod
source 'https://github.com/CocoaPods/Specs.git'
pod 'AFNetworking'
end
config.unstub(:skip_repo_update?)
config.skip_repo_update = false
lockfile = mock
lockfile.stubs(:version).returns(Version.new('1.0'))
lockfile.stubs(:pod_names).returns(%w(AFNetworking))
......
......@@ -7,20 +7,6 @@ module Pod
exception.message.should.include "No `Podfile' found in the project directory."
end
it 'updates the spec repos by default' do
config.with_changes(:skip_repo_update => nil) do
Pod::Command.parse(['update'])
config.skip_repo_update.should.be.false
end
end
it "doesn't update the spec repos if that option was given" do
config.with_changes(:skip_repo_update => nil) do
Pod::Command.parse(['update', '--no-repo-update'])
config.skip_repo_update.should.be.true
end
end
describe 'with Podfile' do
extend SpecHelper::TemporaryRepos
......@@ -32,6 +18,22 @@ module Pod
end
end
describe 'updates of the spec repos' do
before do
Installer.any_instance.expects(:install!)
end
it 'updates the spec repos by default' do
Installer.any_instance.expects(:repo_update=).with(true)
run_command('update')
end
it "doesn't update the spec repos if that option was given" do
Installer.any_instance.expects(:repo_update=).with(false)
run_command('update', '--no-repo-update')
end
end
it 'tells the user that no Lockfile was found in the project dir' do
exception = lambda { run_command('update', 'BananaLib', '--no-repo-update') }.should.raise Informative
exception.message.should.include "No `Podfile.lock' found in the project directory"
......
......@@ -11,7 +11,6 @@ module Bacon
c.silent = true
c.repos_dir = fixture('spec-repos')
c.installation_root = SpecHelper.temporary_directory
c.skip_repo_update = true
c.cache_root = SpecHelper.temporary_directory + 'Cache'
end
......
......@@ -105,7 +105,6 @@ module Pod
end
it 'runs source provider hooks before analyzing' do
config.skip_repo_update = true
@installer.unstub(:resolve_dependencies)
@installer.stubs(:validate_build_configurations)
@installer.stubs(:clean_sandbox)
......@@ -136,7 +135,6 @@ module Pod
@installer.stubs(:clean_sandbox)
@installer.stubs(:ensure_plugins_are_installed!)
@installer.stubs(:analyze)
config.skip_repo_update = true
analyzer = Installer::Analyzer.new(config.sandbox, @installer.podfile, @installer.lockfile)
analyzer.stubs(:analyze)
......@@ -376,14 +374,13 @@ 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
it 'does not updates the repositories by default' do
SourcesManager.expects(:update).never
@installer.send(:resolve_dependencies)
end
it 'updates the repositories by default' do
config.skip_repo_update = false
it 'updates the repositories if that was requested' do
@installer.repo_update = true
SourcesManager.expects(:update).once
@installer.send(:resolve_dependencies)
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