Commit 1a34157e authored by Fabio Pelosin's avatar Fabio Pelosin

[Commands] Fix pod outdated.

parent 792abfd5
...@@ -52,10 +52,10 @@ module Pod ...@@ -52,10 +52,10 @@ module Pod
# @todo We should probably not even load colored unless needed. # @todo We should probably not even load colored unless needed.
# #
def initialize(argv) def initialize(argv)
config.silent ||= argv.flag?('silent') config.silent = argv.flag?('silent', config.silent)
super config.verbose = argv.flag?('verbose', config.verbose?)
config.verbose ||= self.verbose?
String.send(:define_method, :colorize) { |string , _| string } unless self.colorize_output? String.send(:define_method, :colorize) { |string , _| string } unless self.colorize_output?
super
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
......
...@@ -13,32 +13,38 @@ module Pod ...@@ -13,32 +13,38 @@ module Pod
end end
def initialize(argv) def initialize(argv)
config.skip_repo_update = argv.flag?('update', true) config.skip_repo_update = argv.flag?('update', config.skip_repo_update)
super super
end end
# @todo the command report new dependencies added to the Podfile as # @todo the command report new dependencies added to the Podfile as
# updates. # updates.
# @todo fix.
#
def run def run
verify_podfile_exists! verify_podfile_exists!
verify_lockfile_exists! verify_lockfile_exists!
sandbox = Sandbox.new(config.project_pods_root) lockfile = config.lockfile
resolver = Resolver.new(config.podfile, config.lockfile, sandbox) pods = lockfile.pod_names
resolver.update_mode = true updates = []
resolver.update_external_specs = false pods.each do |pod_name|
resolver.resolve set = SourcesManager.search(Dependency.new(pod_name))
source_version = set.versions.first
names = resolver.pods_to_install - resolver.pods_from_external_sources lockfile_version = lockfile.version(pod_name)
specs = resolver.specs.select do |spec| if source_version > lockfile_version
names.include?(spec.name) && !spec.version.head? updates << [pod_name, lockfile_version, source_version]
end
end end
if specs.empty? if updates.empty?
puts "No updates are available.".yellow UI.puts "No updates are available.".yellow
else else
puts "The following updates are available:".green UI.section "The following updates are available:" do
puts " - " << specs.join("\n - ") << "\n" updates.each do |(name, from_version, to_version)|
UI.message "- #{name} #{from_version} -> #{to_version}"
end
end
end end
end end
end end
......
module Pod module Pod
class Command class Command
# Provides support the common behaviour of the `install` and `update`
# commands.
#
module Project module Project
module Options module Options
def options def options
...@@ -16,17 +20,11 @@ module Pod ...@@ -16,17 +20,11 @@ module Pod
base.extend Options base.extend Options
end end
# @todo find a better way to not override the config if the flag was not
# specified. A solution could be a method called only if the flag
# is not nil:
#
# argv.set_flag('clean') { |value| config.clean = value }
#
def initialize(argv) def initialize(argv)
config.clean = value if value = argv.flag?('clean') config.clean = argv.flag?('clean', config.clean)
config.generate_docs = value if value = argv.flag?('doc') config.generate_docs = argv.flag?('doc', config.generate_docs)
config.integrate_targets = value if value = argv.flag?('integrate') config.integrate_targets = argv.flag?('integrate', config.integrate_targets)
config.skip_repo_update = value if value = !argv.flag?('update') config.skip_repo_update = !argv.flag?('update', !config.skip_repo_update)
super super
end end
......
...@@ -3,7 +3,6 @@ require File.expand_path('../../../spec_helper', __FILE__) ...@@ -3,7 +3,6 @@ require File.expand_path('../../../spec_helper', __FILE__)
module Pod module Pod
describe "Command::List" do describe "Command::List" do
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryRepos
before do before do
set_up_test_repo set_up_test_repo
......
...@@ -2,7 +2,6 @@ require File.expand_path('../../../spec_helper', __FILE__) ...@@ -2,7 +2,6 @@ require File.expand_path('../../../spec_helper', __FILE__)
module Pod module Pod
describe Command::Outdated do describe Command::Outdated do
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryRepos
it "tells the user that no Podfile was found in the current working dir" do it "tells the user that no Podfile was found in the current working dir" do
......
...@@ -2,11 +2,32 @@ require File.expand_path('../../../spec_helper', __FILE__) ...@@ -2,11 +2,32 @@ require File.expand_path('../../../spec_helper', __FILE__)
module Pod module Pod
describe Command::Install do describe Command::Install do
it "tells the user that no Podfile or podspec was found in the current working dir" do it "tells the user that no Podfile or podspec was found in the current working dir" do
exception = lambda { run_command('install', '--no-update') }.should.raise Informative exception = lambda { run_command('install', '--no-update') }.should.raise Informative
exception.message.should.include "No `Podfile' found in the current working directory." exception.message.should.include "No `Podfile' found in the current working directory."
end end
end end
#--------------------------------------------------------------------------------#
describe Command::Update do
extend SpecHelper::TemporaryRepos
it "tells the user that no Podfile was found in the current working dir" do
exception = lambda { run_command('update','--no-update') }.should.raise Informative
exception.message.should.include "No `Podfile' found in the current working directory."
end
it "tells the user that no Lockfile was found in the current working dir" do
file = temporary_directory + 'Podfile'
File.open(file, 'w') {|f| f.write('platform :ios') }
Dir.chdir(temporary_directory) do
exception = lambda { run_command('update','--no-update') }.should.raise Informative
exception.message.should.include "No `Podfile.lock' found in the current working directory"
end
end
end
end end
require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe Command::Update do
extend SpecHelper::TemporaryRepos
it "tells the user that no Podfile was found in the current working dir" do
exception = lambda { run_command('update','--no-update') }.should.raise Informative
exception.message.should.include "No `Podfile' found in the current working directory."
end
it "tells the user that no Lockfile was found in the current working dir" do
file = temporary_directory + 'Podfile'
File.open(file, 'w') {|f| f.write('platform :ios') }
Dir.chdir(temporary_directory) do
exception = lambda { run_command('update','--no-update') }.should.raise Informative
exception.message.should.include "No `Podfile.lock' found in the current working directory"
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