summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Wen <jrw2175@columbia.edu>2016-02-18 19:59:47 -0500
committerJames Wen <jrw2175@columbia.edu>2016-02-18 19:59:47 -0500
commitbe60bec5a74952d08667e79b61c0f76e2a73f45a (patch)
tree5dc9ccc19bf44cd1d4ae8393e18d2cd7a660fa9f
parent1328c77a2ae4ac68828f08fad4ff3876c344fc61 (diff)
downloadbundler-be60bec5a74952d08667e79b61c0f76e2a73f45a.tar.gz
Add `--patch` flag for `bundle outdated`
- `bundle outdated --patch` will only report updates in the patch version (v#.#.patch)
-rw-r--r--lib/bundler/cli.rb3
-rw-r--r--lib/bundler/cli/outdated.rb14
-rw-r--r--spec/commands/outdated_spec.rb18
3 files changed, 31 insertions, 4 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 1fed1b58f0..a3ccd70075 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -244,7 +244,8 @@ module Bundler
method_option "strict", :type => :boolean, :banner =>
"Only list newer versions allowed by your Gemfile requirements"
method_option "major", :type => :boolean, :banner => "Only list major newer versions"
- method_option "minor", :type => :boolean, :banner => "Only list at least minor newer versions"
+ method_option "minor", :type => :boolean, :banner => "Only list minor newer versions"
+ method_option "patch", :type => :boolean, :banner => "Only list patch newer versions"
method_option "parseable", :aliases => "--porcelain", :type => :boolean, :banner =>
"Use minimal formatting for more parseable output"
def outdated(*gems)
diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb
index d0ae0b46c5..4296ec630d 100644
--- a/lib/bundler/cli/outdated.rb
+++ b/lib/bundler/cli/outdated.rb
@@ -56,7 +56,7 @@ module Bundler
end
active_spec = active_spec.last
- if options[:major] || options[:minor]
+ if options[:major] || options[:minor] || options[:patch]
update_present = update_present_via_semver_portions(current_spec, active_spec, options)
active_spec = nil unless update_present
end
@@ -126,10 +126,18 @@ module Bundler
update_present = active_major > current_major if options[:major]
- if options[:minor] && current_major == active_major
+ if (options[:minor] || options[:patch]) && current_major == active_major
current_minor = current_spec.version.segments[1, 1].first
active_minor = active_spec.version.segments[1, 1].first
- update_present = active_minor > current_minor
+
+ if options[:minor]
+ update_present = active_minor > current_minor
+ elsif options[:patch] && current_minor == active_minor
+ current_patch = current_spec.version.segments[2, 1].first
+ active_patch = active_spec.version.segments[2, 1].first
+
+ update_present = active_patch > current_patch
+ end
end
update_present
diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb
index 65da3f6ea1..8f961e5a42 100644
--- a/spec/commands/outdated_spec.rb
+++ b/spec/commands/outdated_spec.rb
@@ -321,4 +321,22 @@ describe "bundle outdated" do
it_behaves_like "major version is ignored"
it_behaves_like "patch version is ignored"
end
+
+ describe "with --patch option" do
+ subject { bundle "outdated --patch" }
+
+ it "only reports gems that have a newer patch version" do
+ update_repo2 do
+ build_gem "activesupport", "2.3.7"
+ build_gem "weakling", "0.3.1"
+ end
+
+ subject
+ expect(out).to include("activesupport (newest")
+ expect(out).to_not include("weakling (newest")
+ end
+
+ it_behaves_like "major version is ignored"
+ it_behaves_like "minor version is ignored"
+ end
end