summaryrefslogtreecommitdiff
path: root/lib/bundler/cli
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2016-10-22 07:10:45 +0900
committerHomu <homu@barosl.com>2016-10-22 07:10:45 +0900
commit3ccc0db369267bb477608dfef3b0aa645eeceb33 (patch)
tree3f8fc1ad7d6cd5e38e18547a33b6738730523303 /lib/bundler/cli
parent03c864aa348b056ac2962aa6f3593726ccdad0ae (diff)
parent9c1c3a0e3a3cf5b65b5f6d499eb368de4ec23dff (diff)
downloadbundler-3ccc0db369267bb477608dfef3b0aa645eeceb33.tar.gz
Auto merge of #5061 - chrismo:cons_outdated, r=indirect
Conservative updates on outdated Add conservative resolving behavior to outdated command. - [x] convert existing flags to --filter-* - [x] deal with strict flag - [x] make a 2.0 issue to consider making strict flags more consistent - [x] fix #5065 (outdated filter options don't work with `--strict') - [x] fix #5076 (outdated shouldn't say "Bundle up to date!" if results are just filtered out.) - [ ] document breaking change reasons? (_commit comment has something at least now_) - [x] what about `bundle show --outdated`? (_it's a much simpler version ... prolly just going to leave it alone for now?_) The flags as passed to the GemVersionPromoter _change_ resolution. <=1.13.2 of bundle outdated, those flags merely filter the output, with no influence on resolution. If the lockfile is set to foo 1.0.0, and all of the following exist: 1.0.1, 1.1.0, 2.0.0, then <=1.13.2 bundle outdated currently will show: `foo (newest 2.0.0, installed 1.0.0)` <=1.13.2 `bundle outdated --minor` simply filters away that line and won't show it. With these changes, `bundle outdated --minor` would be fed to the GemVersionPromoter and actually only resolve `foo` up to `1.1.0`. This gist shows how it currently works, filtering the output: https://gist.github.com/chrismo/0bc6cfa00f539787101a9a2c900616d3 It's unfortunate timing. They were only added in 1.12 ... I'm biased, but feel like the affect the flags have on resolution is of greater value, and would be better to keep in sync with how they work fed to the `bundle update` command as of 1.13, and we could add new --filter-patch flags to replace what they do currently. IIRC, there was some confusion at the time that Andre perhaps even thought these flags as of 1.12 would be affecting what the newest would resolve to, instead of just filtering the output, so - _if_ I'm remembering correctly, that's also influencing my opinion. But, I can be swayed by the breaking behavior argument. from @indirect in [this comment](https://github.com/bundler/bundler/pull/4841#discussion_r82021277): "IMO, this is what we were trying to do in 1.12, and failed to do because resolving is complicated. :/ I would be okay with this change on the grounds that the previous flags were documented so it sounded like they cause the new resolver aware behavior. 👍"
Diffstat (limited to 'lib/bundler/cli')
-rw-r--r--lib/bundler/cli/common.rb10
-rw-r--r--lib/bundler/cli/lock.rb2
-rw-r--r--lib/bundler/cli/outdated.rb36
-rw-r--r--lib/bundler/cli/update.rb2
4 files changed, 35 insertions, 15 deletions
diff --git a/lib/bundler/cli/common.rb b/lib/bundler/cli/common.rb
index 6f45322db8..40a429bac4 100644
--- a/lib/bundler/cli/common.rb
+++ b/lib/bundler/cli/common.rb
@@ -53,13 +53,17 @@ module Bundler
message
end
- def self.config_gem_version_promoter(definition, opts)
- patch_level = [:major, :minor, :patch].select {|v| opts.keys.include?(v.to_s) }
+ def self.configure_gem_version_promoter(definition, options)
+ patch_level = patch_level_options(options)
raise InvalidOption, "Provide only one of the following options: #{patch_level.join(", ")}" unless patch_level.length <= 1
definition.gem_version_promoter.tap do |gvp|
gvp.level = patch_level.first || :major
- gvp.strict = opts[:strict]
+ gvp.strict = options[:strict] || options["update-strict"]
end
end
+
+ def self.patch_level_options(options)
+ [:major, :minor, :patch].select {|v| options.keys.include?(v.to_s) }
+ end
end
end
diff --git a/lib/bundler/cli/lock.rb b/lib/bundler/cli/lock.rb
index 225a07aa97..2ccaba86eb 100644
--- a/lib/bundler/cli/lock.rb
+++ b/lib/bundler/cli/lock.rb
@@ -25,7 +25,7 @@ module Bundler
update = { :gems => update, :lock_shared_dependencies => options[:conservative] } if update.is_a?(Array)
definition = Bundler.definition(update)
- Bundler::CLI::Common.config_gem_version_promoter(Bundler.definition, options) if options[:update]
+ Bundler::CLI::Common.configure_gem_version_promoter(Bundler.definition, options) if options[:update]
options["remove-platform"].each do |platform|
definition.remove_platform(platform)
diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb
index 5729c07ffe..1d5b8e0242 100644
--- a/lib/bundler/cli/outdated.rb
+++ b/lib/bundler/cli/outdated.rb
@@ -31,6 +31,10 @@ module Bundler
Bundler.definition(:gems => gems, :sources => sources)
end
+ Bundler::CLI::Common.configure_gem_version_promoter(Bundler.definition, options)
+ # the patch level options don't work without strict also being true
+ strict = options[:strict] || Bundler::CLI::Common.patch_level_options(options).any?
+
definition_resolution = proc { options[:local] ? definition.resolve_with_cache! : definition.resolve_remotely! }
if options[:parseable]
Bundler.ui.silence(&definition_resolution)
@@ -49,7 +53,7 @@ module Bundler
dependency = current_dependencies[current_spec.name]
- if options[:strict]
+ if strict
active_spec = definition.specs.detect {|spec| spec.name == current_spec.name && spec.platform == current_spec.platform }
else
active_specs = definition.index[current_spec.name].select {|spec| spec.platform == current_spec.platform }.sort_by(&:version)
@@ -57,11 +61,11 @@ module Bundler
active_spec = active_specs.delete_if {|b| b.respond_to?(:version) && b.version.prerelease? }
end
active_spec = active_specs.last
+ end
- 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
+ if options["filter-major"] || options["filter-minor"] || options["filter-patch"]
+ update_present = update_present_via_semver_portions(current_spec, active_spec, options)
+ active_spec = nil unless update_present
end
next if active_spec.nil?
@@ -90,7 +94,7 @@ module Bundler
end
if outdated_gems_list.empty?
- Bundler.ui.info "Bundle up to date!\n" unless options[:parseable]
+ display_nothing_outdated_message
else
unless options[:parseable]
if options[:pre]
@@ -137,6 +141,18 @@ module Bundler
private
+ def display_nothing_outdated_message
+ unless options[:parseable]
+ filter_options = options.keys & %w(filter-major filter-minor filter-patch)
+ if filter_options.any?
+ display = filter_options.map {|o| o.sub("filter-", "") }.join(" or ")
+ Bundler.ui.info "No #{display} updates to display.\n"
+ else
+ Bundler.ui.info "Bundle up to date!\n"
+ end
+ end
+ end
+
def print_gem(current_spec, active_spec, dependency, groups, options_include_groups)
spec_version = "#{active_spec.version}#{active_spec.git_version}"
current_version = "#{current_spec.version}#{current_spec.git_version}"
@@ -167,15 +183,15 @@ module Bundler
active_major = active_spec.version.segments.first
update_present = false
- update_present = active_major > current_major if options[:major]
+ update_present = active_major > current_major if options["filter-major"]
- if !update_present && (options[:minor] || options[:patch]) && current_major == active_major
+ if !update_present && (options["filter-minor"] || options["filter-patch"]) && current_major == active_major
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]
+ update_present = active_minor > current_minor if options["filter-minor"]
- if !update_present && options[:patch] && current_minor == active_minor
+ if !update_present && options["filter-patch"] && current_minor == active_minor
current_patch = get_version_semver_portion_value(current_spec, 2)
active_patch = get_version_semver_portion_value(active_spec, 2)
diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb
index 585fe38e17..bc8231d367 100644
--- a/lib/bundler/cli/update.rb
+++ b/lib/bundler/cli/update.rb
@@ -41,7 +41,7 @@ module Bundler
:lock_shared_dependencies => options[:conservative])
end
- Bundler::CLI::Common.config_gem_version_promoter(Bundler.definition, options)
+ Bundler::CLI::Common.configure_gem_version_promoter(Bundler.definition, options)
Bundler::Fetcher.disable_endpoint = options["full-index"]