diff options
author | David Blondeau <david@collaborativedrug.com> | 2013-10-24 23:09:08 -0700 |
---|---|---|
committer | David Blondeau <david@collaborativedrug.com> | 2013-10-24 23:28:34 -0700 |
commit | 0c38ee142ecf20f32ec4b175ac7d2b3c3b17991e (patch) | |
tree | 0e440059a3bdc917f4e5863ae47e28af4059023b | |
parent | 51cbb6b3d026f5635ae66a279a0a7f69be4b4351 (diff) | |
download | bundler-0c38ee142ecf20f32ec4b175ac7d2b3c3b17991e.tar.gz |
bundle outdated --strict
Only reports newer versions that match dependency requirements
-rw-r--r-- | lib/bundler/cli.rb | 15 | ||||
-rw-r--r-- | spec/commands/outdated_spec.rb | 17 |
2 files changed, 28 insertions, 4 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index c9d2771097..4af2ee79e7 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 that match 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" |