summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Arko <andre@arko.net>2013-10-29 11:29:39 -0700
committerAndré Arko <andre@arko.net>2013-10-29 11:29:39 -0700
commitc76badc30c9ddd158073206d2dead44026bab387 (patch)
tree97ad50d1e79ae785184931034caa36cd848235a8
parent42c8a80004c7b2ede0c6d271e97db67272ba4767 (diff)
parent06ae0ac740c502775feebc4421235ba20b0fa90d (diff)
downloadbundler-c76badc30c9ddd158073206d2dead44026bab387.tar.gz
Merge pull request #2685 from davidblondeau/outdated-strict
bundle outdated --strict
-rw-r--r--lib/bundler/cli.rb15
-rw-r--r--spec/commands/outdated_spec.rb17
2 files changed, 28 insertions, 4 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index c9d2771097..b0a7241fde 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -416,6 +416,8 @@ module Bundler
method_option "source", :type => :array, :banner => "Check against a specific source"
method_option "local", :type => :boolean, :banner =>
"Do not attempt to fetch gems remotely and use the gem cache instead"
+ method_option "strict", :type => :boolean, :banner =>
+ "Only list newer versions allowed by your Gemfile requirements"
def outdated(*gems)
sources = Array(options[:source])
@@ -444,13 +446,19 @@ module Bundler
[gemfile_specs.sort_by(&:name), dependency_specs.sort_by(&:name)].flatten.each do |current_spec|
next if !gems.empty? && !gems.include?(current_spec.name)
- active_spec = definition.index[current_spec.name].sort_by { |b| b.version }
+ dependency = current_dependencies[current_spec.name]
+ active_spec = definition.index[current_spec.name].sort_by { |b| b.version }
if !current_spec.version.prerelease? && !options[:pre] && active_spec.size > 1
active_spec = active_spec.delete_if { |b| b.respond_to?(:version) && b.version.prerelease? }
end
-
- active_spec = active_spec.last
+ if options["strict"]
+ active_spec = active_spec.reverse.detect do |b|
+ dependency && b.respond_to?(:version) && dependency.requirement.satisfied_by?(b.version)
+ end || active_spec.last
+ else
+ active_spec = active_spec.last
+ end
next if active_spec.nil?
gem_outdated = Gem::Version.new(active_spec.version) > Gem::Version.new(current_spec.version)
@@ -466,7 +474,6 @@ module Bundler
spec_version = "#{active_spec.version}#{active_spec.git_version}"
current_version = "#{current_spec.version}#{current_spec.git_version}"
- dependency = current_dependencies[current_spec.name]
dependency_version = %|Gemfile specifies "#{dependency.requirement}"| if dependency && dependency.specific?
Bundler.ui.info " * #{active_spec.name} (#{spec_version} > #{current_version}) #{dependency_version}".rstrip
out_count += 1
diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb
index 0c8de2adfe..4e19d5ad95 100644
--- a/spec/commands/outdated_spec.rb
+++ b/spec/commands/outdated_spec.rb
@@ -12,6 +12,7 @@ describe "bundle outdated" do
gem "zebra", :git => "#{lib_path('zebra')}"
gem "foo", :git => "#{lib_path('foo')}"
gem "activesupport", "2.3.5"
+ gem "weakling", "~> 0.0.1"
G
end
@@ -19,6 +20,7 @@ describe "bundle outdated" do
it "returns a sorted list of outdated gems" do
update_repo2 do
build_gem "activesupport", "3.0"
+ build_gem "weakling", "0.2"
update_git "foo", :path => lib_path("foo")
update_git "zebra", :path => lib_path("zebra")
end
@@ -26,6 +28,7 @@ describe "bundle outdated" do
bundle "outdated"
expect(out).to include("activesupport (3.0 > 2.3.5) Gemfile specifies \"= 2.3.5\"")
+ expect(out).to include("weakling (0.2 > 0.0.3) Gemfile specifies \"~> 0.0.1\"")
expect(out).to include("foo (1.0")
# Gem names are one per-line, between "*" and their parenthesized version.
@@ -114,6 +117,20 @@ describe "bundle outdated" do
end
end
+ describe "with --strict option" do
+ it "only reports gems that have a newer version that matches the specified dependency version requirements" do
+ update_repo2 do
+ build_gem "activesupport", "3.0"
+ build_gem "weakling", "0.0.5"
+ end
+
+ bundle "outdated --strict"
+
+ expect(out).to_not include("activesupport (3.0 > 2.3.5) Gemfile specifies \"= 2.3.5\"")
+ expect(out).to include("weakling (0.0.5 > 0.0.3) Gemfile specifies \"~> 0.0.1\"")
+ end
+ end
+
describe "with invalid gem name" do
it "returns could not find gem name" do
bundle "outdated invalid_gem_name"