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

[Resolver] Lazy repo update.

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