Unverified Commit 94a66195 authored by Dimitris Koutsogiorgas's avatar Dimitris Koutsogiorgas Committed by GitHub

Merge pull request #7204 from iv-mexx/master

Add color indication to output of "pod outdated"
parents 5c0bd2c8 91e23205
......@@ -8,6 +8,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Enhancements
* Add color indication to output of `pod outdated`
[iv-mexx](https://github.com/iv-mexx)
[#7204](https://github.com/CocoaPods/CocoaPods/pull/7204)
* Add support for editing the podspec, license, README, license, and docs of local development pods
[Eric Amorde](https://github.com/amorde)
[#7093](https://github.com/CocoaPods/CocoaPods/pull/7093)
......
......@@ -22,10 +22,24 @@ module Pod
if updates.empty?
UI.puts 'No pod updates are available.'.yellow
else
UI.section 'The color indicates what happens when you run `pod update`' do
UI.puts "#{'<green>'.green}\t\t - Will be updated to the newest version"
UI.puts "#{'<yellow>'.yellow}\t - Will be updated, but not to the newest version because of specified version in Podfile"
UI.puts "#{'<red>'.red}\t\t - Will not be updated because of specified version in Podfile"
UI.puts ''
end
UI.section 'The following pod updates are available:' do
updates.each do |(name, from_version, matching_version, to_version)|
UI.puts "- #{name} #{from_version} -> #{matching_version} " \
"(latest version #{to_version})"
color = :yellow
if matching_version == to_version
color = :green
elsif from_version == matching_version
color = :red
end
# For the specs, its necessary that to_s is called here even though it is redundant
# https://github.com/CocoaPods/CocoaPods/pull/7204#issuecomment-342512015
UI.puts "- #{name} #{from_version.to_s.send(color)} -> #{matching_version.to_s.send(color)} " \
"(latest version #{to_version.to_s})" # rubocop:disable Lint/StringConversionInInterpolation
end
end
end
......
require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe Command::Outdated do
extend SpecHelper::TemporaryRepos
......@@ -39,6 +38,65 @@ module Pod
UI.output.should.not.include('UIKit')
end
it 'tells the user about outdated pods that can be updated in green' do
pod_name = 'BlocksKit'
current_version_string = mock
current_version_string.expects(:green).returns('1.0').once
current_version = mock
current_version.stubs(:to_s).returns(current_version_string)
newest_version_string = mock
newest_version_string.stubs(:to_s).returns('2.0')
newest_version_string.expects(:green).returns('2.0').once
newest_version = mock
newest_version.stubs(:to_s).returns(newest_version_string)
Command::Outdated.any_instance.stubs(:updates).returns([[pod_name, current_version, newest_version, newest_version]])
Command::Outdated.any_instance.stubs(:deprecated_pods).returns([])
run_command('outdated')
UI.output.should.include('BlocksKit 1.0 -> 2.0 (latest version 2.0)')
end
it 'tells the user about outdated pods that can not be updated due to version restriction in red' do
pod_name = 'BlocksKit'
version_string = mock
version_string.expects(:red).returns('1.0').twice
current_version = mock
current_version.stubs(:to_s).returns(version_string)
newest_version = mock
newest_version.stubs(:to_s).returns('2.0')
Command::Outdated.any_instance.stubs(:updates).returns([[pod_name, current_version, current_version, newest_version]])
Command::Outdated.any_instance.stubs(:deprecated_pods).returns([])
run_command('outdated')
UI.output.should.include('BlocksKit 1.0 -> 1.0 (latest version 2.0)')
end
it 'tells the user about outdated pods that can be updated, but not to the latest version in yellow' do
pod_name = 'BlocksKit'
current_version_string = mock
current_version_string.expects(:yellow).returns('1.0').once
current_version = mock
current_version.stubs(:to_s).returns(current_version_string)
next_version_string = mock
next_version_string.expects(:yellow).returns('1.1').once
next_version = mock
next_version.stubs(:to_s).returns(next_version_string)
newest_version = mock
newest_version.stubs(:to_s).returns('2.0')
Command::Outdated.any_instance.stubs(:updates).returns([[pod_name, current_version, next_version, newest_version]])
Command::Outdated.any_instance.stubs(:deprecated_pods).returns([])
run_command('outdated')
UI.output.should.include('BlocksKit 1.0 -> 1.1 (latest version 2.0)')
end
it 'tells the user about deprecated pods' do
spec = Specification.new(nil, 'AFNetworking')
spec.deprecated_in_favor_of = 'BlocksKit'
......
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