summaryrefslogtreecommitdiff
path: root/lib/bundler
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2021-11-11 10:40:30 +0900
committernagachika <nagachika@ruby-lang.org>2021-11-22 10:51:35 +0900
commit31a71048521224774bdb8b5982ab73eb35dad66d (patch)
tree8174af2f04f4b31abf0f4ab08d779055f513cdaa /lib/bundler
parent6d540c1b9844a5832846618b53ce35d12d64deac (diff)
Merge RubyGems 3.2.27 and Bundler 2.2.27
Diffstat (limited to 'lib/bundler')
-rw-r--r--lib/bundler/cli/check.rb2
-rw-r--r--lib/bundler/definition.rb6
-rw-r--r--lib/bundler/installer.rb1
-rw-r--r--lib/bundler/plugin.rb29
-rw-r--r--lib/bundler/plugin/installer.rb2
-rw-r--r--lib/bundler/rubygems_integration.rb2
-rw-r--r--lib/bundler/settings.rb10
-rw-r--r--lib/bundler/source.rb2
-rw-r--r--lib/bundler/source/rubygems.rb9
-rw-r--r--lib/bundler/source_list.rb4
-rw-r--r--lib/bundler/spec_set.rb2
-rw-r--r--lib/bundler/templates/newgem/github/workflows/main.yml.tt3
-rw-r--r--lib/bundler/version.rb2
13 files changed, 61 insertions, 13 deletions
diff --git a/lib/bundler/cli/check.rb b/lib/bundler/cli/check.rb
index 4221fc7f2b..65c51337d2 100644
--- a/lib/bundler/cli/check.rb
+++ b/lib/bundler/cli/check.rb
@@ -15,7 +15,7 @@ module Bundler
definition.validate_runtime!
begin
- definition.resolve_with_cache!
+ definition.resolve_only_locally!
not_installed = definition.missing_specs
rescue GemNotFound, VersionConflict
Bundler.ui.error "Bundler can't satisfy your Gemfile's dependencies."
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 673bf37698..4a27c438f5 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -161,6 +161,12 @@ module Bundler
@multisource_allowed
end
+ def resolve_only_locally!
+ @remote = false
+ sources.local_only!
+ resolve
+ end
+
def resolve_with_cache!
sources.cached!
resolve
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index 2624ac4b18..63e02ba496 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -1,6 +1,5 @@
# frozen_string_literal: true
-require "rubygems/dependency_installer"
require_relative "worker"
require_relative "installer/parallel_installer"
require_relative "installer/standalone"
diff --git a/lib/bundler/plugin.rb b/lib/bundler/plugin.rb
index bfe4fd7286..158c69e1a1 100644
--- a/lib/bundler/plugin.rb
+++ b/lib/bundler/plugin.rb
@@ -13,6 +13,7 @@ module Bundler
class MalformattedPlugin < PluginError; end
class UndefinedCommandError < PluginError; end
class UnknownSourceError < PluginError; end
+ class PluginInstallError < PluginError; end
PLUGIN_FILE_NAME = "plugins.rb".freeze
@@ -38,12 +39,11 @@ module Bundler
specs = Installer.new.install(names, options)
save_plugins names, specs
- rescue PluginError => e
+ rescue PluginError
specs_to_delete = specs.select {|k, _v| names.include?(k) && !index.commands.values.include?(k) }
specs_to_delete.each_value {|spec| Bundler.rm_rf(spec.full_gem_path) }
- names_list = names.map {|name| "`#{name}`" }.join(", ")
- Bundler.ui.error "Failed to install the following plugins: #{names_list}. The underlying error was: #{e.message}.\n #{e.backtrace.join("\n ")}"
+ raise
end
# Uninstalls plugins by the given names
@@ -245,10 +245,11 @@ module Bundler
# @param [Array<String>] names of inferred source plugins that can be ignored
def save_plugins(plugins, specs, optional_plugins = [])
plugins.each do |name|
+ next if index.installed?(name)
+
spec = specs[name]
- validate_plugin! Pathname.new(spec.full_gem_path)
- installed = register_plugin(name, spec, optional_plugins.include?(name))
- Bundler.ui.info "Installed plugin #{name}" if installed
+
+ save_plugin(name, spec, optional_plugins.include?(name))
end
end
@@ -263,6 +264,22 @@ module Bundler
raise MalformattedPlugin, "#{PLUGIN_FILE_NAME} was not found in the plugin." unless plugin_file.file?
end
+ # Validates and registers a plugin.
+ #
+ # @param [String] name the name of the plugin
+ # @param [Specification] spec of installed plugin
+ # @param [Boolean] optional_plugin, removed if there is conflict with any
+ # other plugin (used for default source plugins)
+ #
+ # @raise [PluginInstallError] if validation or registration raises any error
+ def save_plugin(name, spec, optional_plugin = false)
+ validate_plugin! Pathname.new(spec.full_gem_path)
+ installed = register_plugin(name, spec, optional_plugin)
+ Bundler.ui.info "Installed plugin #{name}" if installed
+ rescue PluginError => e
+ raise PluginInstallError, "Failed to install plugin `#{spec.name}`, due to #{e.class} (#{e.message})"
+ end
+
# Runs the plugins.rb file in an isolated namespace, records the plugin
# actions it registers for and then passes the data to index to be stored.
#
diff --git a/lib/bundler/plugin/installer.rb b/lib/bundler/plugin/installer.rb
index 54ce8528cf..d7411fff45 100644
--- a/lib/bundler/plugin/installer.rb
+++ b/lib/bundler/plugin/installer.rb
@@ -81,6 +81,8 @@ module Bundler
deps = names.map {|name| Dependency.new name, version }
+ Bundler.configure_gem_home_and_path(Plugin.root)
+
definition = Definition.new(nil, deps, source_list, true)
install_definition(definition)
end
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb
index 21ce12ecda..98982b0f07 100644
--- a/lib/bundler/rubygems_integration.rb
+++ b/lib/bundler/rubygems_integration.rb
@@ -34,10 +34,12 @@ module Bundler
end
def build_args
+ require "rubygems/command"
Gem::Command.build_args
end
def build_args=(args)
+ require "rubygems/command"
Gem::Command.build_args = args
end
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index abf7db21b4..1ced590b6f 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -419,7 +419,15 @@ module Bundler
elsif is_credential(key)
"[REDACTED]"
elsif is_userinfo(converted)
- converted.gsub(/:.*$/, ":[REDACTED]")
+ username, pass = converted.split(":", 2)
+
+ if pass == "x-oauth-basic"
+ username = "[REDACTED]"
+ else
+ pass = "[REDACTED]"
+ end
+
+ [username, pass].join(":")
else
converted
end
diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb
index 7bf493d73d..434112ac8a 100644
--- a/lib/bundler/source.rb
+++ b/lib/bundler/source.rb
@@ -36,6 +36,8 @@ module Bundler
def local!; end
+ def local_only!; end
+
def cached!; end
def remote!; end
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
index 298ff98e24..7f8699b91c 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -26,6 +26,13 @@ module Bundler
Array(options["remotes"]).reverse_each {|r| add_remote(r) }
end
+ def local_only!
+ @specs = nil
+ @allow_local = true
+ @allow_cached = false
+ @allow_remote = false
+ end
+
def local!
return if @allow_local
@@ -137,7 +144,7 @@ module Bundler
end
end
- if (installed?(spec) || Plugin.installed?(spec.name)) && !force
+ if installed?(spec) && !force
print_using_message "Using #{version_message(spec)}"
return nil # no post-install message
end
diff --git a/lib/bundler/source_list.rb b/lib/bundler/source_list.rb
index b97206f497..d6310b78c0 100644
--- a/lib/bundler/source_list.rb
+++ b/lib/bundler/source_list.rb
@@ -136,6 +136,10 @@ module Bundler
different_sources?(lock_sources, replacement_sources)
end
+ def local_only!
+ all_sources.each(&:local_only!)
+ end
+
def cached!
all_sources.each(&:cached!)
end
diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb
index 7be4fcca87..26d41cb9b8 100644
--- a/lib/bundler/spec_set.rb
+++ b/lib/bundler/spec_set.rb
@@ -24,7 +24,7 @@ module Bundler
specs_for_dep = spec_for_dependency(dep, match_current_platform)
if specs_for_dep.any?
- specs += specs_for_dep
+ match_current_platform ? specs += specs_for_dep : specs |= specs_for_dep
specs_for_dep.first.dependencies.each do |d|
next if d.type == :development
diff --git a/lib/bundler/templates/newgem/github/workflows/main.yml.tt b/lib/bundler/templates/newgem/github/workflows/main.yml.tt
index 83ddea25dc..952cd649a2 100644
--- a/lib/bundler/templates/newgem/github/workflows/main.yml.tt
+++ b/lib/bundler/templates/newgem/github/workflows/main.yml.tt
@@ -2,7 +2,8 @@ name: Ruby
on:
push:
- - <%= config[:git_default_branch] %>
+ branches:
+ - <%= config[:git_default_branch] %>
pull_request:
diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb
index 510953c543..690d5a511c 100644
--- a/lib/bundler/version.rb
+++ b/lib/bundler/version.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
module Bundler
- VERSION = "2.2.26".freeze
+ VERSION = "2.2.27".freeze
def self.bundler_major_version
@bundler_major_version ||= VERSION.split(".").first.to_i