Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/bundler/cli/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def run
setup_cache_all
install

# TODO: move cache contents here now that all bundles are locked
custom_path = Bundler.settings[:path] if options[:path]

Bundler.settings.temporary(cache_all_platforms: options["all-platforms"]) do
Expand Down
11 changes: 1 addition & 10 deletions lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -645,20 +645,12 @@ def filter_specs(specs, deps, skips: [])
end

def materialize(dependencies)
# Tracks potential endless loops trying to re-resolve.
# TODO: Remove as dead code if not reports are received in a while
incorrect_spec = nil

specs = begin
resolve.materialize(dependencies)
rescue IncorrectLockfileDependencies => e
raise if Bundler.frozen_bundle?

spec = e.spec
raise "Infinite loop while fixing lockfile dependencies" if incorrect_spec == spec

incorrect_spec = spec
reresolve_without([spec])
reresolve_without([e.spec])
retry
end

Expand Down Expand Up @@ -740,7 +732,6 @@ def reresolve_without(incomplete_specs)
def start_resolution
local_platform_needed_for_resolvability = @most_specific_non_local_locked_platform && !@platforms.include?(Bundler.local_platform)
@platforms << Bundler.local_platform if local_platform_needed_for_resolvability
add_platform(Gem::Platform::RUBY) if RUBY_ENGINE == "truffleruby"

result = SpecSet.new(resolver.start)

Expand Down
1 change: 1 addition & 0 deletions lib/bundler/resolver/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def initialize(name, platforms, locked_specs:, unlock:, prerelease: false, prefe
@locked_version = locked_specs.version_for(name)
@unlock = unlock
@dependency = dependency || Dependency.new(name, @locked_version)
@platforms |= [Gem::Platform::RUBY] if @dependency.default_force_ruby_platform
@top_level = !dependency.nil?
@prerelease = @dependency.prerelease? || @locked_version&.prerelease? || prerelease ? :consider_first : :ignore
@prefer_local = prefer_local
Expand Down
6 changes: 1 addition & 5 deletions lib/bundler/source/path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,7 @@ def expanded_path
end

def expand(somepath)
if Bundler.current_ruby.jruby? # TODO: Unify when https://github.com/rubygems/bundler/issues/7598 fixed upstream and all supported jrubies include the fix
somepath.expand_path(root_path).expand_path
else
somepath.expand_path(root_path)
end
somepath.expand_path(root_path)
rescue ArgumentError => e
Bundler.ui.debug(e)
raise PathError, "There was an error while trying to use the path " \
Expand Down
48 changes: 42 additions & 6 deletions lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,35 @@ def inject_into_module(path, module_name, *args, &block)
insert_into_file(path, *(args << config), &block)
end

# Run a regular expression replacement on a file, raising an error if the
# contents of the file are not changed.
#
# ==== Parameters
# path<String>:: path of the file to be changed
# flag<Regexp|String>:: the regexp or string to be replaced
# replacement<String>:: the replacement, can be also given as a block
# config<Hash>:: give :verbose => false to not log the status, and
# :force => true, to force the replacement regardless of runner behavior.
#
# ==== Example
#
# gsub_file! 'app/controllers/application_controller.rb', /#\s*(filter_parameter_logging :password)/, '\1'
#
# gsub_file! 'README', /rake/, :green do |match|
# match << " no more. Use thor!"
# end
#
def gsub_file!(path, flag, *args, &block)
config = args.last.is_a?(Hash) ? args.pop : {}

return unless behavior == :invoke || config.fetch(:force, false)

path = File.expand_path(path, destination_root)
say_status :gsub, relative_to_original_destination_root(path), config.fetch(:verbose, true)

actually_gsub_file(path, flag, args, true, &block) unless options[:pretend]
end

# Run a regular expression replacement on a file.
#
# ==== Parameters
Expand All @@ -267,11 +296,7 @@ def gsub_file(path, flag, *args, &block)
path = File.expand_path(path, destination_root)
say_status :gsub, relative_to_original_destination_root(path), config.fetch(:verbose, true)

unless options[:pretend]
content = File.binread(path)
content.gsub!(flag, *args, &block)
File.open(path, "wb") { |file| file.write(content) }
end
actually_gsub_file(path, flag, args, false, &block) unless options[:pretend]
end

# Uncomment all lines matching a given regex. Preserves indentation before
Expand Down Expand Up @@ -348,7 +373,7 @@ def capture(*args)
end

def with_output_buffer(buf = "".dup) #:nodoc:
raise ArgumentError, "Buffer can not be a frozen object" if buf.frozen?
raise ArgumentError, "Buffer cannot be a frozen object" if buf.frozen?
old_buffer = output_buffer
self.output_buffer = buf
yield
Expand All @@ -357,6 +382,17 @@ def with_output_buffer(buf = "".dup) #:nodoc:
self.output_buffer = old_buffer
end

def actually_gsub_file(path, flag, args, error_on_no_change, &block)
content = File.binread(path)
success = content.gsub!(flag, *args, &block)

if success.nil? && error_on_no_change
raise Bundler::Thor::Error, "The content of #{path} did not change"
end

File.open(path, "wb") { |file| file.write(content) }
end

# Bundler::Thor::Actions#capture depends on what kind of buffer is used in ERB.
# Thus CapturableERB fixes ERB to use String buffer.
class CapturableERB < ERB
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/vendor/thor/lib/thor/parser/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def parse(args) # rubocop:disable Metrics/MethodLength
def check_exclusive!
opts = @assigns.keys
# When option A and B are exclusive, if A and B are given at the same time,
# the diffrence of argument array size will decrease.
# the difference of argument array size will decrease.
found = @exclusives.find{ |ex| (ex - opts).size < ex.size - 1 }
if found
names = names_to_switch_names(found & opts).map{|n| "'#{n}'"}
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/vendor/thor/lib/thor/runner.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require_relative "../thor"
require_relative "group"

require "yaml"
require "digest/sha2"
require "pathname"

Expand Down Expand Up @@ -195,6 +194,7 @@ def thor_root
def thor_yaml
@thor_yaml ||= begin
yaml_file = File.join(thor_root, "thor.yml")
require "yaml"
yaml = YAML.load_file(yaml_file) if File.exist?(yaml_file)
yaml || {}
end
Expand Down
10 changes: 3 additions & 7 deletions lib/bundler/vendor/thor/lib/thor/shell/basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def show_diff(destination, content) #:nodoc:
diff_cmd = ENV["THOR_DIFF"] || ENV["RAILS_DIFF"] || "diff -u"

require "tempfile"
Tempfile.open(File.basename(destination), File.dirname(destination)) do |temp|
Tempfile.open(File.basename(destination), File.dirname(destination), binmode: true) do |temp|
temp.write content
temp.rewind
system %(#{diff_cmd} "#{destination}" "#{temp.path}")
Expand Down Expand Up @@ -372,16 +372,12 @@ def merge(destination, content) #:nodoc:
Tempfile.open([File.basename(destination), File.extname(destination)], File.dirname(destination)) do |temp|
temp.write content
temp.rewind
system %(#{merge_tool} "#{temp.path}" "#{destination}")
system(merge_tool, temp.path, destination)
end
end

def merge_tool #:nodoc:
@merge_tool ||= ENV["THOR_MERGE"] || git_merge_tool
end

def git_merge_tool #:nodoc:
`git config merge.tool`.rstrip rescue ""
@merge_tool ||= ENV["THOR_MERGE"] || "git difftool --no-index"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/vendor/thor/lib/thor/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class Bundler::Thor
VERSION = "1.3.2"
VERSION = "1.4.0"
end
1 change: 0 additions & 1 deletion spec/bundler/commands/lock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2237,7 +2237,6 @@
nokogiri (1.14.2-x86_64-linux)

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
Expand Down
18 changes: 17 additions & 1 deletion spec/bundler/install/gemfile/specific_platform_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,23 @@
end
end

it "installs sorbet-static, which does not provide a pure ruby variant, just fine", :truffleruby do
it "installs sorbet-static, which does not provide a pure ruby variant, in absence of a lockfile, just fine", :truffleruby do
skip "does not apply to Windows" if Gem.win_platform?

build_repo2 do
build_gem("sorbet-static", "0.5.6403") {|s| s.platform = Bundler.local_platform }
end

gemfile <<~G
source "https://gem.repo2"

gem "sorbet-static", "0.5.6403"
G

bundle "install --verbose"
end

it "installs sorbet-static, which does not provide a pure ruby variant, in presence of a lockfile, just fine", :truffleruby do
skip "does not apply to Windows" if Gem.win_platform?

build_repo2 do
Expand Down
4 changes: 2 additions & 2 deletions spec/bundler/realworld/fixtures/tapioca/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ GEM
spoom (>= 1.2.0)
thor (>= 1.2.0)
yard-sorbet
thor (1.3.2)
thor (1.4.0)
yard (0.9.37)
yard-sorbet (0.9.0)
sorbet-runtime
Expand All @@ -46,4 +46,4 @@ DEPENDENCIES
tapioca

BUNDLED WITH
2.7.0.dev
2.8.0.dev
2 changes: 1 addition & 1 deletion spec/bundler/realworld/fixtures/warbler/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ DEPENDENCIES
warbler!

BUNDLED WITH
2.7.0.dev
2.8.0.dev
2 changes: 1 addition & 1 deletion tool/bundler/vendor_gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
gem "resolv", "0.6.2"
gem "securerandom", "0.4.1"
gem "timeout", "0.4.3"
gem "thor", "1.3.2"
gem "thor", "1.4.0"
gem "tsort", "0.2.0"
gem "uri", "1.0.3"
6 changes: 3 additions & 3 deletions tool/bundler/vendor_gems.rb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ GEM
optparse (0.6.0)
resolv (0.6.2)
securerandom (0.4.1)
thor (1.3.2)
thor (1.4.0)
timeout (0.4.3)
tsort (0.2.0)
uri (1.0.3)
Expand All @@ -60,7 +60,7 @@ DEPENDENCIES
pub_grub!
resolv (= 0.6.2)
securerandom (= 0.4.1)
thor (= 1.3.2)
thor (= 1.4.0)
timeout (= 0.4.3)
tsort (= 0.2.0)
uri (= 1.0.3)
Expand All @@ -76,7 +76,7 @@ CHECKSUMS
pub_grub (0.5.0)
resolv (0.6.2) sha256=61efe545cedddeb1b14f77e51f85c85ca66af5098fdbf567fadf32c34590fb14
securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
thor (1.3.2) sha256=eef0293b9e24158ccad7ab383ae83534b7ad4ed99c09f96f1a6b036550abbeda
thor (1.4.0) sha256=8763e822ccb0f1d7bee88cde131b19a65606657b847cc7b7b4b82e772bcd8a3d
timeout (0.4.3) sha256=9509f079b2b55fe4236d79633bd75e34c1c1e7e3fb4b56cb5fda61f80a0fe30e
tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f
uri (1.0.3) sha256=e9f2244608eea2f7bc357d954c65c910ce0399ca5e18a7a29207ac22d8767011
Expand Down