summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2017-04-03 19:09:08 +0000
committerThe Bundler Bot <bot@bundler.io>2017-04-03 19:09:08 +0000
commite6b9688d6eb087babf9a8a20d4d6c09c67745cb3 (patch)
tree65a6df2cb93024f1be7896c7f8421782230a8c5b
parent7c1dc7ef164f845b3c07fc8fe731ea041c476ef1 (diff)
parent48ca5adedefcf13bf50331858ba0a53ae6aab478 (diff)
downloadbundler-e6b9688d6eb087babf9a8a20d4d6c09c67745cb3.tar.gz
Auto merge of #5555 - bundler:seg-outdated-new-machine, r=indirect
[Outdated] Support running when gems are not yet installed Closes #5553
-rw-r--r--lib/bundler/cli/outdated.rb34
-rw-r--r--lib/bundler/lazy_specification.rb5
-rw-r--r--lib/bundler/ui/shell.rb15
-rw-r--r--spec/bundler/ui_spec.rb14
-rw-r--r--spec/commands/outdated_spec.rb15
5 files changed, 59 insertions, 24 deletions
diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb
index 93e50b10b6..863d0dd388 100644
--- a/lib/bundler/cli/outdated.rb
+++ b/lib/bundler/cli/outdated.rb
@@ -20,7 +20,7 @@ module Bundler
end
Bundler.definition.validate_runtime!
- current_specs = Bundler.ui.silence { Bundler.load.specs }
+ current_specs = Bundler.ui.silence { Bundler.definition.resolve }
current_dependencies = {}
Bundler.ui.silence do
Bundler.load.dependencies.each do |dep|
@@ -80,25 +80,22 @@ module Bundler
end
gem_outdated = Gem::Version.new(active_spec.version) > Gem::Version.new(current_spec.version)
- if gem_outdated || (current_spec.git_version != active_spec.git_version)
- groups = nil
- if dependency && !options[:parseable]
- groups = dependency.groups.join(", ")
- end
-
- outdated_gems_list << { :active_spec => active_spec,
- :current_spec => current_spec,
- :dependency => dependency,
- :groups => groups }
-
- outdated_gems_by_groups[groups] ||= []
- outdated_gems_by_groups[groups] << { :active_spec => active_spec,
- :current_spec => current_spec,
- :dependency => dependency,
- :groups => groups }
+ next unless gem_outdated || (current_spec.git_version != active_spec.git_version)
+ groups = nil
+ if dependency && !options[:parseable]
+ groups = dependency.groups.join(", ")
end
- Bundler.ui.debug "from #{active_spec.loaded_from}"
+ outdated_gems_list << { :active_spec => active_spec,
+ :current_spec => current_spec,
+ :dependency => dependency,
+ :groups => groups }
+
+ outdated_gems_by_groups[groups] ||= []
+ outdated_gems_by_groups[groups] << { :active_spec => active_spec,
+ :current_spec => current_spec,
+ :dependency => dependency,
+ :groups => groups }
end
if outdated_gems_list.empty?
@@ -195,6 +192,7 @@ module Bundler
def print_gem(current_spec, active_spec, dependency, groups, options_include_groups)
spec_version = "#{active_spec.version}#{active_spec.git_version}"
+ spec_version += " (from #{active_spec.loaded_from})" if Bundler.ui.debug? && active_spec.loaded_from
current_version = "#{current_spec.version}#{current_spec.git_version}"
if dependency && dependency.specific?
diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb
index 891495c1d4..231bffcae8 100644
--- a/lib/bundler/lazy_specification.rb
+++ b/lib/bundler/lazy_specification.rb
@@ -99,6 +99,11 @@ module Bundler
@__identifier ||= Identifier.new(name, version, source, platform, dependencies)
end
+ def git_version
+ return unless source.is_a?(Bundler::Source::Git)
+ " #{source.revision[0..6]}"
+ end
+
private
def to_ary
diff --git a/lib/bundler/ui/shell.rb b/lib/bundler/ui/shell.rb
index 697290f795..87a92471fb 100644
--- a/lib/bundler/ui/shell.rb
+++ b/lib/bundler/ui/shell.rb
@@ -40,16 +40,15 @@ module Bundler
end
def debug(msg, newline = nil)
- tell_me(msg, nil, newline) if level("debug")
+ tell_me(msg, nil, newline) if debug?
end
def debug?
- # needs to be false instead of nil to be newline param to other methods
- level("debug") ? true : false
+ level("debug")
end
def quiet?
- LEVELS.index(@level) <= LEVELS.index("warn")
+ level("quiet")
end
def ask(msg)
@@ -66,11 +65,15 @@ module Bundler
def level=(level)
raise ArgumentError unless LEVELS.include?(level.to_s)
- @level = level
+ @level = level.to_s
end
def level(name = nil)
- name ? LEVELS.index(name) <= LEVELS.index(@level) : @level
+ return @level unless name
+ unless index = LEVELS.index(name)
+ raise "#{name.inspect} is not a valid level"
+ end
+ index <= LEVELS.index(@level)
end
def trace(e, newline = nil, force = false)
diff --git a/spec/bundler/ui_spec.rb b/spec/bundler/ui_spec.rb
index 41c037527b..fc76eb1ee7 100644
--- a/spec/bundler/ui_spec.rb
+++ b/spec/bundler/ui_spec.rb
@@ -25,4 +25,18 @@ RSpec.describe Bundler::UI do
expect(methods.call(described_class)).to eq(methods.call(shell))
end
end
+
+ describe Bundler::UI::Shell do
+ let(:options) { {} }
+ subject { described_class.new(options) }
+ describe "debug?" do
+ it "returns a boolean" do
+ subject.level = :debug
+ expect(subject.debug?).to eq(true)
+
+ subject.level = :error
+ expect(subject.debug?).to eq(false)
+ end
+ end
+ end
end
diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb
index b927a0be2b..c6b6c9f59e 100644
--- a/spec/commands/outdated_spec.rb
+++ b/spec/commands/outdated_spec.rb
@@ -489,6 +489,21 @@ RSpec.describe "bundle outdated" do
it_behaves_like "version update is detected"
end
+ context "when on a new machine" do
+ before do
+ simulate_new_machine
+
+ update_git "foo", :path => lib_path("foo")
+ update_repo2 do
+ build_gem "activesupport", "3.3.5"
+ build_gem "weakling", "0.8.0"
+ end
+ end
+
+ subject { bundle "outdated" }
+ it_behaves_like "version update is detected"
+ end
+
shared_examples_for "minor version updates are detected" do
before do
update_repo2 do