summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Wen <jrw2175@columbia.edu>2016-04-21 01:38:57 -0400
committerJames Wen <jrw2175@columbia.edu>2016-04-21 09:29:57 -0400
commitb1ddf72874d8d8992f60eb88301c9067e8064481 (patch)
tree3ca26bf82bad7566bb7ce81fa09cd3d335ba3f58
parent64a4ab7b25b83eddbfc95d48bc624f6f51b31857 (diff)
downloadbundler-b1ddf72874d8d8992f60eb88301c9067e8064481.tar.gz
Fix `bundle outdated` with `--patch` and/or `--minor` for
non-semantically versioned gems - Examples of non-semantic versions: "7.0", "8"
-rw-r--r--lib/bundler/cli/outdated.rb13
-rw-r--r--spec/commands/outdated_spec.rb6
-rw-r--r--spec/support/builders.rb4
3 files changed, 19 insertions, 4 deletions
diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb
index bd7d1bd520..c184f317d5 100644
--- a/lib/bundler/cli/outdated.rb
+++ b/lib/bundler/cli/outdated.rb
@@ -127,14 +127,14 @@ module Bundler
update_present = active_major > current_major if options[:major]
if !update_present && (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
+ current_minor = get_version_semver_portion_value(current_spec, 1)
+ active_minor = get_version_semver_portion_value(active_spec, 1)
update_present = active_minor > current_minor if options[:minor]
if !update_present && options[:patch] && current_minor == active_minor
- current_patch = current_spec.version.segments[2, 1].first
- active_patch = active_spec.version.segments[2, 1].first
+ current_patch = get_version_semver_portion_value(current_spec, 2)
+ active_patch = get_version_semver_portion_value(active_spec, 2)
update_present = active_patch > current_patch
end
@@ -142,5 +142,10 @@ module Bundler
update_present
end
+
+ def get_version_semver_portion_value(spec, version_portion_index)
+ version_section = spec.version.segments[version_portion_index, 1]
+ version_section.nil? ? 0 : (version_section.first || 0)
+ end
end
end
diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb
index 7f699f035d..d61d316011 100644
--- a/spec/commands/outdated_spec.rb
+++ b/spec/commands/outdated_spec.rb
@@ -14,6 +14,8 @@ describe "bundle outdated" do
gem "foo", :git => "#{lib_path("foo")}"
gem "activesupport", "2.3.5"
gem "weakling", "~> 0.0.1"
+ gem "duradura", '7.0'
+ gem "terranova", '8'
G
end
@@ -244,7 +246,9 @@ describe "bundle outdated" do
shared_examples_for "version update is detected" do
it "reports that a gem has a newer version" do
subject
+ expect(out).to include("Outdated gems included in the bundle:")
expect(out).to include("activesupport (newest")
+ expect(out).to_not include("ERROR REPORT TEMPLATE")
end
end
@@ -284,6 +288,8 @@ describe "bundle outdated" do
shared_examples_for "no version updates are detected" do
it "does not detect any version updates" do
subject
+ expect(out).to include("Bundle up to date!")
+ expect(out).to_not include("ERROR REPORT TEMPLATE")
expect(out).to_not include("activesupport (newest")
expect(out).to_not include("weakling (newest")
end
diff --git a/spec/support/builders.rb b/spec/support/builders.rb
index 54f6889be7..6b7edbf85a 100644
--- a/spec/support/builders.rb
+++ b/spec/support/builders.rb
@@ -122,6 +122,10 @@ module Spec
build_gem "weakling", "0.0.3"
+ build_gem "terranova", "8"
+
+ build_gem "duradura", "7.0"
+
build_gem "multiple_versioned_deps" do |s|
s.add_dependency "weakling", ">= 0.0.1", "< 0.1"
end