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

[Commands] Fix pod outdated.

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