aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/cli.rb42
-rw-r--r--lib/bundler/cli/clean.rb2
-rw-r--r--lib/bundler/cli/common.rb10
-rw-r--r--lib/bundler/cli/lock.rb4
-rw-r--r--lib/bundler/cli/outdated.rb36
-rw-r--r--lib/bundler/cli/update.rb5
-rw-r--r--lib/bundler/definition.rb9
-rw-r--r--lib/bundler/gemdeps.rb28
-rw-r--r--lib/bundler/index.rb3
-rw-r--r--lib/bundler/rubygems_integration.rb12
-rw-r--r--lib/bundler/version.rb2
11 files changed, 115 insertions, 38 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index f92ecb1c..37556f49 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -215,14 +215,16 @@ module Bundler
"Update ruby specified in Gemfile.lock"
method_option "bundler", :type => :string, :lazy_default => "> 0.a", :banner =>
"Update the locked version of bundler"
- method_option "patch", :type => :boolean, :hide => true, :banner =>
+ method_option "patch", :type => :boolean, :banner =>
"Prefer updating only to next patch version"
- method_option "minor", :type => :boolean, :hide => true, :banner =>
+ method_option "minor", :type => :boolean, :banner =>
"Prefer updating only to next minor version"
- method_option "major", :type => :boolean, :hide => true, :banner =>
+ method_option "major", :type => :boolean, :banner =>
"Prefer updating to next major version (default)"
- method_option "strict", :type => :boolean, :hide => true, :banner =>
+ method_option "strict", :type => :boolean, :banner =>
"Do not allow any gem to be updated past latest --patch/--minor/--major"
+ method_option "conservative", :type => :boolean, :banner =>
+ "Use bundle install conservative update behavior and do not allowed shared dependencies to be updated."
def update(*gems)
require "bundler/cli/update"
Update.new(options, gems).run
@@ -268,6 +270,9 @@ module Bundler
in the given source. Calling outdated with [GEM [GEM]] will only check for newer
versions of the given gems. Prerelease gems are ignored by default. If your gems
are up to date, Bundler will exit with a status of 0. Otherwise, it will exit 1.
+
+ For more information on conservative resolution options (--major, --minor,
+ --patch, --strict) see documentation on the same options on the update command.
D
method_option "group", :aliases => "--group", :type => :string, :banner => "List gems from a specific group"
method_option "groups", :aliases => "--groups", :type => :boolean, :banner => "List gems organized by groups"
@@ -277,9 +282,14 @@ module Bundler
method_option "source", :type => :array, :banner => "Check against a specific source"
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 minor newer versions"
- method_option "patch", :type => :boolean, :banner => "Only list patch newer versions"
+ method_option "update-strict", :type => :boolean, :banner =>
+ "Strict conservative resolution, do not allow any gem to be updated past latest --patch/--minor/--major"
+ method_option "minor", :type => :boolean, :banner => "Prefer updating only to next minor version"
+ method_option "major", :type => :boolean, :banner => "Prefer updating to next major version (default)"
+ method_option "patch", :type => :boolean, :banner => "Prefer updating only to next patch version"
+ method_option "filter-major", :type => :boolean, :banner => "Only list major newer versions"
+ method_option "filter-minor", :type => :boolean, :banner => "Only list minor newer versions"
+ method_option "filter-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)
@@ -459,14 +469,16 @@ module Bundler
"add a new platform to the lockfile"
method_option "remove-platform", :type => :array, :default => [], :banner =>
"remove a platform from the lockfile"
- method_option "patch", :type => :boolean, :hide => true, :banner =>
- "Prefer updating only to next patch version"
- method_option "minor", :type => :boolean, :hide => true, :banner =>
- "Prefer updating only to next minor version"
- method_option "major", :type => :boolean, :hide => true, :banner =>
- "Prefer updating to next major version (default)"
- method_option "strict", :type => :boolean, :hide => true, :banner =>
- "Do not allow any gem to be updated past latest --patch/--minor/--major"
+ method_option "patch", :type => :boolean, :banner =>
+ "If updating, prefer updating only to next patch version"
+ method_option "minor", :type => :boolean, :banner =>
+ "If updating, prefer updating only to next minor version"
+ method_option "major", :type => :boolean, :banner =>
+ "If updating, prefer updating to next major version (default)"
+ method_option "strict", :type => :boolean, :banner =>
+ "If updating, do not allow any gem to be updated past latest --patch | --minor | --major"
+ method_option "conservative", :type => :boolean, :banner =>
+ "If updating, use bundle install conservative update behavior and do not allowed shared dependencies to be updated."
def lock
require "bundler/cli/lock"
Lock.new(options).run
diff --git a/lib/bundler/cli/clean.rb b/lib/bundler/cli/clean.rb
index 895b6567..5eba09c6 100644
--- a/lib/bundler/cli/clean.rb
+++ b/lib/bundler/cli/clean.rb
@@ -8,7 +8,7 @@ module Bundler
end
def run
- require_path_or_force
+ require_path_or_force unless options[:"dry-run"]
Bundler.load.clean(options[:"dry-run"])
end
diff --git a/lib/bundler/cli/common.rb b/lib/bundler/cli/common.rb
index 6f45322d..40a429ba 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 eb47c9ef..2ccaba86 100644
--- a/lib/bundler/cli/lock.rb
+++ b/lib/bundler/cli/lock.rb
@@ -22,10 +22,10 @@ module Bundler
Bundler::Fetcher.disable_endpoint = options["full-index"]
update = options[:update]
- update = { :gems => update } if update.is_a?(Array)
+ 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 5729c07f..1d5b8e02 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 51de98bf..bc8231d3 100644
--- a/lib/bundler/cli/update.rb
+++ b/lib/bundler/cli/update.rb
@@ -37,10 +37,11 @@ module Bundler
gems.concat(specs.map(&:name))
end
- Bundler.definition(:gems => gems, :sources => sources, :ruby => options[:ruby])
+ Bundler.definition(:gems => gems, :sources => sources, :ruby => options[:ruby],
+ :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"]
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 8a6bf0d1..b9ac233f 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -105,8 +105,11 @@ module Bundler
add_current_platform unless Bundler.settings[:frozen]
@path_changes = converge_paths
- eager_unlock = expand_dependencies(@unlock[:gems])
- @unlock[:gems] = @locked_specs.for(eager_unlock).map(&:name)
+
+ unless @unlock[:lock_shared_dependencies]
+ eager_unlock = expand_dependencies(@unlock[:gems])
+ @unlock[:gems] = @locked_specs.for(eager_unlock).map(&:name)
+ end
@gem_version_promoter = create_gem_version_promoter
@@ -173,7 +176,7 @@ module Bundler
rescue GemNotFound => e # Handle yanked gem
gem_name, gem_version = extract_gem_info(e)
locked_gem = @locked_specs[gem_name].last
- raise if locked_gem.nil? || locked_gem.version.to_s != gem_version
+ raise if locked_gem.nil? || locked_gem.version.to_s != gem_version || !@remote
raise GemNotFound, "Your bundle is locked to #{locked_gem}, but that version could not " \
"be found in any of the sources listed in your Gemfile. If you haven't changed sources, " \
"that means the author of #{locked_gem} has removed it. You'll need to update your bundle " \
diff --git a/lib/bundler/gemdeps.rb b/lib/bundler/gemdeps.rb
new file mode 100644
index 00000000..8595b8c7
--- /dev/null
+++ b/lib/bundler/gemdeps.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+module Bundler
+ class Gemdeps
+ def initialize(runtime)
+ @runtime = runtime
+ end
+
+ def requested_specs
+ @runtime.requested_specs
+ end
+
+ def specs
+ @runtime.specs
+ end
+
+ def dependencies
+ @runtime.dependencies
+ end
+
+ def current_dependencies
+ @runtime.current_dependencies
+ end
+
+ def requires
+ @runtime.requires
+ end
+ end
+end
diff --git a/lib/bundler/index.rb b/lib/bundler/index.rb
index 4529c572..5bdb102d 100644
--- a/lib/bundler/index.rb
+++ b/lib/bundler/index.rb
@@ -179,7 +179,8 @@ module Bundler
end
wants_prerelease = dependency.requirement.prerelease?
- only_prerelease = specs.all? {|spec| spec.version.prerelease? }
+ wants_prerelease ||= base && base.any? {|base_spec| base_spec.version.prerelease? }
+ only_prerelease = specs.all? {|spec| spec.version.prerelease? }
unless wants_prerelease || only_prerelease
found.reject! {|spec| spec.version.prerelease? }
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb
index 90da0b46..ec1a4087 100644
--- a/lib/bundler/rubygems_integration.rb
+++ b/lib/bundler/rubygems_integration.rb
@@ -353,6 +353,10 @@ module Bundler
true
end
+
+ # TODO: delete this in 2.0, it's a backwards compatibility shim
+ # see https://github.com/bundler/bundler/issues/5102
+ kernel_class.send(:public, :gem)
end
end
@@ -751,6 +755,14 @@ module Bundler
end.map(&:to_spec)
end
end
+
+ def use_gemdeps(gemfile)
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path(gemfile)
+ runtime = Bundler.setup
+ Bundler.ui = nil
+ activated_spec_names = runtime.requested_specs.map(&:to_spec).sort_by(&:name)
+ [Gemdeps.new(runtime), activated_spec_names]
+ end
end
end
diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb
index 15914837..9cd9fb00 100644
--- a/lib/bundler/version.rb
+++ b/lib/bundler/version.rb
@@ -7,5 +7,5 @@ module Bundler
# We're doing this because we might write tests that deal
# with other versions of bundler and we are unsure how to
# handle this better.
- VERSION = "1.13.3" unless defined?(::Bundler::VERSION)
+ VERSION = "1.13.6" unless defined?(::Bundler::VERSION)
end