Commit 8fe92e1e authored by Fabio Pelosin's avatar Fabio Pelosin

[Resolver] Lazy repo update.

parent b8ef7bf5
......@@ -142,14 +142,6 @@ module Pod
raise Informative, "No `Podfile.lock' found in the current working directory, run `pod install'."
end
end
def update_spec_repos_if_necessary!
if @update_repo
UI.section 'Updating Spec Repositories' do
Repo.new(ARGV.new(["update"])).run
end
end
end
end
end
......@@ -35,7 +35,7 @@ module Pod
config.clean = !argv.option('--no-clean')
config.generate_docs = !argv.option('--no-doc')
config.integrate_targets = !argv.option('--no-integrate')
@update_repo = !argv.option('--no-update')
config.skip_repo_update = !argv.option('--no-update')
super unless argv.empty?
end
......@@ -48,7 +48,6 @@ module Pod
def run
verify_podfile_exists!
update_spec_repos_if_necessary!
run_install_with_update(false)
end
end
......
......@@ -11,13 +11,11 @@ module Pod
end
def self.options
[
["--no-update", "Skip running `pod repo update` before install"],
].concat(super)
[["--no-update", "Skip running `pod repo update` before install"]].concat(super)
end
def initialize(argv)
@update_repo = !argv.option('--no-update')
config.skip_repo_update = argv.option('--no-update')
super unless argv.empty?
end
......
......@@ -9,10 +9,18 @@ module Pod
Updates all dependencies.}
end
def self.options
[["--no-update", "Skip running `pod repo update` before install"]].concat(super)
end
def initialize(argv)
config.skip_repo_update = argv.option('--no-update')
super unless argv.empty?
end
def run
verify_podfile_exists!
verify_lockfile_exists!
update_spec_repos_if_necessary!
run_install_with_update(true)
end
end
......
......@@ -14,7 +14,7 @@ module Pod
attr_accessor :clean, :verbose, :silent
attr_accessor :generate_docs, :doc_install
attr_accessor :integrate_targets
attr_accessor :new_version_message
attr_accessor :new_version_message, :skip_repo_update
alias_method :clean?, :clean
alias_method :verbose?, :verbose
......@@ -22,11 +22,12 @@ module Pod
alias_method :generate_docs?, :generate_docs
alias_method :doc_install?, :doc_install
alias_method :integrate_targets?, :integrate_targets
alias_method :skip_repo_update?, :skip_repo_update
alias_method :new_version_message?, :new_version_message
def initialize
@repos_dir = Pathname.new(File.expand_path("~/.cocoapods"))
@verbose = @silent = false
@verbose = @silent = @skip_repo_update = false
@clean = @generate_docs = @doc_install = @integrate_targets = @new_version_message = true
end
......
......@@ -80,6 +80,12 @@ module Pod
@pods_to_lock = (lockfile.pods_names - @pods_by_state[:added] - @pods_by_state[:changed] - @pods_by_state[:removed]).uniq
end
unless config.skip_repo_update?
UI.section 'Updating Spec Repositories' do
Command::Repo.new(Command::ARGV.new(["update"])).run
end if !@pods_by_state || !(@pods_by_state[:added] + @pods_by_state[:changed]).empty? || update_mode
end
@podfile.target_definitions.values.each do |target_definition|
UI.section "Resolving dependencies for target `#{target_definition.name}' (#{target_definition.platform}):" do
@loaded_specs = []
......
......@@ -27,9 +27,9 @@ else
extend SpecHelper::TemporaryDirectory
def create_config!
config.repos_dir = fixture('spec-repos')
config.project_root = temporary_directory
config.integrate_targets = false
config.repos_dir = fixture('spec-repos')
config.project_root = temporary_directory
config.integrate_targets = false
end
before do
......@@ -208,7 +208,6 @@ else
result['DEPENDENCIES'].should == ["ASIHTTPRequest", "JSONKit (= 1.4)"]
# TODO might be nicer looking to not show the dependencies of the top level spec for each subspec (Reachability).
should_xcodebuild(podfile.target_definitions[:ios_target])
should_xcodebuild(podfile.target_definitions[:osx_target])
end
......@@ -217,10 +216,11 @@ else
::Pod::Config.instance = nil
::Pod::Config.instance.tap do |c|
ENV['VERBOSE_SPECS'] ? c.verbose = true : c.silent = true
c.doc_install = false
c.repos_dir = fixture('spec-repos')
c.project_root = temporary_directory
c.integrate_targets = false
c.doc_install = false
c.repos_dir = fixture('spec-repos')
c.project_root = temporary_directory
c.integrate_targets = false
c.skip_repo_update = true
end
Pod::Generator::Documentation.any_instance.stubs(:already_installed?).returns(false)
......
......@@ -8,10 +8,11 @@ module Bacon
::Pod::Config.instance = nil
::Pod::Config.instance.tap do |c|
ENV['VERBOSE_SPECS'] ? c.verbose = true : c.silent = true
c.repos_dir = SpecHelper.tmp_repos_path
c.project_root = SpecHelper.temporary_directory
c.doc_install = false
c.generate_docs = false
c.repos_dir = SpecHelper.tmp_repos_path
c.project_root = SpecHelper.temporary_directory
c.doc_install = false
c.generate_docs = false
c.skip_repo_update = true
end
old_run_requirement.bind(self).call(description, spec)
end
......
......@@ -4,7 +4,6 @@ module Pod
describe Resolver do
before do
config.repos_dir = fixture('spec-repos')
@podfile = Podfile.new do
platform :ios
pod 'BlocksKit'
......@@ -261,7 +260,7 @@ module Pod
platform :ios
pod 'JSONKit'
pod 'BlocksKit'
pod 'libPusher'
pod 'libPusher' # New pod
end
@resolver = Resolver.new(podfile, @lockfile, stub('sandbox'))
installed = @resolver.resolve.values.flatten.map(&:to_s)
......@@ -294,6 +293,56 @@ module Pod
@resolver.resolve
@resolver.should_install?("JSONKit").should.be.false
end
it "doesn't updates the repos if there no change in the pods" do
podfile = Podfile.new do
platform :ios
pod 'BlocksKit'
pod 'JSONKit'
end
config.skip_repo_update = false
Pod::Command::Repo.any_instance.expects(:run).never
@resolver = Resolver.new(podfile, @lockfile, stub('sandbox'))
@resolver.resolve
end
it "updates the repos if there is a new pod" do
podfile = Podfile.new do
platform :ios
pod 'BlocksKit'
pod 'JSONKit'
pod 'libPusher' # New pod
end
config.skip_repo_update = false
Pod::Command::Repo.any_instance.expects(:run).once
@resolver = Resolver.new(podfile, @lockfile, stub('sandbox'))
@resolver.resolve
end
it "doesn't update the repos if config indicate to skip it in any case" do
podfile = Podfile.new do
platform :ios
pod 'BlocksKit'
pod 'JSONKit', :head #changed to head
pod 'libPusher' # New pod
end
config.skip_repo_update = true
Pod::Command::Repo.any_instance.expects(:run).never
@resolver = Resolver.new(podfile, @lockfile, stub('sandbox'))
@resolver.resolve
end
it "updates the repos if there is a new pod" do
podfile = Podfile.new do
platform :ios
pod 'BlocksKit'
pod 'JSONKit', :head #changed to head
end
config.skip_repo_update = false
Pod::Command::Repo.any_instance.expects(:run).once
@resolver = Resolver.new(podfile, @lockfile, stub('sandbox'))
@resolver.resolve
end
end
describe "Concerning Update mode" do
......@@ -356,6 +405,19 @@ module Pod
@resolver.should_install?("libPusher").should.be.true
end
it "always updates the repos even if there is change in the pods" do
podfile = Podfile.new do
platform :ios
pod 'JSONKit'
pod 'libPusher'
end
config.skip_repo_update = false
Pod::Command::Repo.any_instance.expects(:run).once
@resolver = Resolver.new(podfile, @lockfile, stub('sandbox'))
@resolver.update_mode = true
@resolver.resolve
end
# TODO: stub the specification resolution for the sandbox
xit "it always suggests to update pods from external sources" do
podfile = Podfile.new 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