rubygems-update 3.3.0 → 3.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +49 -0
  3. data/Manifest.txt +1 -0
  4. data/bundler/CHANGELOG.md +30 -0
  5. data/bundler/lib/bundler/.document +1 -0
  6. data/bundler/lib/bundler/build_metadata.rb +2 -2
  7. data/bundler/lib/bundler/cli/install.rb +0 -3
  8. data/bundler/lib/bundler/definition.rb +1 -4
  9. data/bundler/lib/bundler/ruby_version.rb +1 -1
  10. data/bundler/lib/bundler/rubygems_gem_installer.rb +1 -1
  11. data/bundler/lib/bundler/self_manager.rb +28 -7
  12. data/bundler/lib/bundler/settings.rb +1 -0
  13. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +6 -6
  14. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +5 -3
  15. data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +6 -2
  16. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
  17. data/bundler/lib/bundler/vendor/thor/lib/thor/error.rb +9 -4
  18. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +19 -1
  19. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +22 -4
  20. data/bundler/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  21. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  22. data/bundler/lib/bundler/version.rb +1 -1
  23. data/lib/rubygems/bundler_version_finder.rb +10 -42
  24. data/lib/rubygems/commands/update_command.rb +4 -3
  25. data/lib/rubygems/dependency.rb +7 -7
  26. data/lib/rubygems/errors.rb +0 -3
  27. data/lib/rubygems/exceptions.rb +7 -3
  28. data/lib/rubygems/security/policy.rb +1 -3
  29. data/lib/rubygems/security.rb +10 -4
  30. data/lib/rubygems/specification.rb +1 -4
  31. data/lib/rubygems/stub_specification.rb +1 -1
  32. data/lib/rubygems.rb +31 -34
  33. data/rubygems-update.gemspec +1 -1
  34. data/test/rubygems/test_gem.rb +0 -35
  35. data/test/rubygems/test_gem_bundler_version_finder.rb +22 -43
  36. data/test/rubygems/test_gem_commands_install_command.rb +33 -0
  37. data/test/rubygems/test_gem_commands_update_command.rb +25 -0
  38. data/test/rubygems/test_gem_dependency.rb +4 -8
  39. data/test/rubygems/test_gem_installer.rb +0 -27
  40. data/test/rubygems/test_gem_stream_ui.rb +1 -1
  41. data/test/rubygems/test_kernel.rb +1 -13
  42. data/test/rubygems/test_require.rb +0 -25
  43. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54e94fde92dd221d68a39c5ec1116f860999c9ea55f744ff77b02e84fca6f580
4
- data.tar.gz: 79682c276c94ea4e5a51d44f62f24ba38af3c41b6fda47a7ff58352143f517c0
3
+ metadata.gz: a8b1ab86a06b30bdc5a03f3124e2e2c7ac40db3e5c5fb5d2e2ae9f42c6bfd549
4
+ data.tar.gz: c885501752d796f4a2b656a537242e889c04bb1e67f1d6d21da9047225e5d89f
5
5
  SHA512:
6
- metadata.gz: 72363f1d7b5ba733226562c433807f0ed13543e598adc030f274db516cacac54d7e748907db269a0fd1b8ada7a567986ddfe8db25a848a4edad8203301bcf02c
7
- data.tar.gz: 3c5c777ac829d9af2533e7717a4a3814266d8fc0b9c2f634a2e4173fc1763a0d80c15ffa02ec5c0ffb1ce9edc893f4121a3f9cf6731d3919532a006536e2b52b
6
+ metadata.gz: bb514eb2ad2813f5ecf90fbe3ffd1c04bf5af6b34cad1b18f77da08a99c0755b18af42314c2ca1073b2d8af58db2eee81a946dd1890c5098ddaabf263cace321
7
+ data.tar.gz: 978538c03440b713418a53126275355e4b0cc3bf31ea0b6574c1813fcaa8b9efe643dcde824a48b2f19eebdf706d5aeba6a10e6ae488e928cf3058f00e2c6e9a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,52 @@
1
+ # 3.3.4 / 2021-12-29
2
+
3
+ ## Enhancements:
4
+
5
+ * Don't redownload `rubygems-update` package if already there. Pull
6
+ request #5230 by deivid-rodriguez
7
+ * Installs bundler 2.3.4 as a default gem.
8
+
9
+ ## Bug fixes:
10
+
11
+ * Fix `gem update --system` crashing when latest version not supported.
12
+ Pull request #5191 by deivid-rodriguez
13
+
14
+ ## Performance:
15
+
16
+ * Make SpecificationPolicy autoload constant. Pull request #5222 by pocke
17
+
18
+ # 3.3.3 / 2021-12-24
19
+
20
+ ## Enhancements:
21
+
22
+ * Installs bundler 2.3.3 as a default gem.
23
+
24
+ ## Bug fixes:
25
+
26
+ * Fix gem installation failing in Solaris due to bad `IO#flock` usage.
27
+ Pull request #5216 by mame
28
+
29
+ # 3.3.2 / 2021-12-23
30
+
31
+ ## Enhancements:
32
+
33
+ * Fix deprecations when activating DidYouMean for misspelled command
34
+ suggestions. Pull request #5211 by yuki24
35
+ * Installs bundler 2.3.2 as a default gem.
36
+
37
+ ## Bug fixes:
38
+
39
+ * Fix gemspec truncation. Pull request #5208 by deivid-rodriguez
40
+
41
+ # 3.3.1 / 2021-12-22
42
+
43
+ ## Enhancements:
44
+
45
+ * Fix compatibility with OpenSSL 3.0. Pull request #5196 by rhenium
46
+ * Remove hard errors when matching major bundler not found. Pull request
47
+ #5181 by deivid-rodriguez
48
+ * Installs bundler 2.3.1 as a default gem.
49
+
1
50
  # 3.3.0 / 2021-12-21
2
51
 
3
52
  ## Breaking changes:
data/Manifest.txt CHANGED
@@ -18,6 +18,7 @@ bundler/bundler.gemspec
18
18
  bundler/exe/bundle
19
19
  bundler/exe/bundler
20
20
  bundler/lib/bundler.rb
21
+ bundler/lib/bundler/.document
21
22
  bundler/lib/bundler/build_metadata.rb
22
23
  bundler/lib/bundler/capistrano.rb
23
24
  bundler/lib/bundler/cli.rb
data/bundler/CHANGELOG.md CHANGED
@@ -1,3 +1,33 @@
1
+ # 2.3.4 (December 29, 2021)
2
+
3
+ ## Enhancements:
4
+
5
+ - Improve error message when `BUNDLED WITH` version does not exist [#5205](https://github.com/rubygems/rubygems/pull/5205)
6
+
7
+ ## Bug fixes:
8
+
9
+ - Fix `bundle update --bundler` no longer updating lockfile [#5224](https://github.com/rubygems/rubygems/pull/5224)
10
+
11
+ # 2.3.3 (December 24, 2021)
12
+
13
+ ## Bug fixes:
14
+
15
+ - Fix locked bundler not installed to the right path when `deployment` is set [#5217](https://github.com/rubygems/rubygems/pull/5217)
16
+
17
+ # 2.3.2 (December 23, 2021)
18
+
19
+ ## Enhancements:
20
+
21
+ - Remove unnecessary lockfile upgrade warning [#5209](https://github.com/rubygems/rubygems/pull/5209)
22
+
23
+ # 2.3.1 (December 22, 2021)
24
+
25
+ ## Enhancements:
26
+
27
+ - Vendor latest `thor` with fixes for latest `did_you_mean` deprecations [#5202](https://github.com/rubygems/rubygems/pull/5202)
28
+ - Avoid unnecessary `shellwords` require on newer rubygems [#5195](https://github.com/rubygems/rubygems/pull/5195)
29
+ - Re-exec prepending command with `Gem.ruby` if `$PROGRAM_NAME` is not executable [#5193](https://github.com/rubygems/rubygems/pull/5193)
30
+
1
31
  # 2.3.0 (December 21, 2021)
2
32
 
3
33
  ## Features:
@@ -0,0 +1 @@
1
+ # not in RDoc
@@ -4,8 +4,8 @@ module Bundler
4
4
  # Represents metadata from when the Bundler gem was built.
5
5
  module BuildMetadata
6
6
  # begin ivars
7
- @built_at = "2021-12-21".freeze
8
- @git_commit_sha = "e7167b9a42".freeze
7
+ @built_at = "2021-12-29".freeze
8
+ @git_commit_sha = "2296a0d6cc".freeze
9
9
  @release = true
10
10
  # end ivars
11
11
 
@@ -165,9 +165,6 @@ module Bundler
165
165
 
166
166
  def normalize_settings
167
167
  Bundler.settings.set_command_option :path, nil if options[:system]
168
- Bundler.settings.temporary(:path_relative_to_cwd => false) do
169
- Bundler.settings.set_command_option :path, "vendor/bundle" if Bundler.settings[:deployment] && Bundler.settings[:path].nil?
170
- end
171
168
  Bundler.settings.set_command_option_if_given :path, options[:path]
172
169
  Bundler.settings.temporary(:path_relative_to_cwd => false) do
173
170
  Bundler.settings.set_command_option :path, "bundle" if options["standalone"] && Bundler.settings[:path].nil?
@@ -292,10 +292,7 @@ module Bundler
292
292
  locked_major = @locked_bundler_version.segments.first
293
293
  current_major = Gem::Version.create(Bundler::VERSION).segments.first
294
294
 
295
- if updating_major = locked_major < current_major
296
- Bundler.ui.warn "Warning: the lockfile is being updated to Bundler #{current_major}, " \
297
- "after which you will be unable to return to Bundler #{locked_major}."
298
- end
295
+ updating_major = locked_major < current_major
299
296
  end
300
297
 
301
298
  preserve_unknown_sections ||= !updating_major && (Bundler.frozen_bundle? || !(unlocking? || @unlocking_bundler))
@@ -103,7 +103,7 @@ module Bundler
103
103
 
104
104
  def self.system
105
105
  ruby_engine = RUBY_ENGINE.dup
106
- ruby_version = ENV.fetch("BUNDLER_SPEC_RUBY_VERSION") { RUBY_VERSION }.dup
106
+ ruby_version = RUBY_VERSION.dup
107
107
  ruby_engine_version = RUBY_ENGINE_VERSION.dup
108
108
  patchlevel = RUBY_PATCHLEVEL.to_s
109
109
 
@@ -67,7 +67,7 @@ module Bundler
67
67
  def build_extensions
68
68
  extension_cache_path = options[:bundler_extension_cache_path]
69
69
  unless extension_cache_path && extension_dir = spec.extension_dir
70
- require "shellwords" # compensate missing require in rubygems before version 3.2.25
70
+ require "shellwords" unless Bundler.rubygems.provides?(">= 3.2.25")
71
71
  return super
72
72
  end
73
73
 
@@ -15,10 +15,6 @@ module Bundler
15
15
  def install_locked_bundler_and_restart_with_it_if_needed
16
16
  return unless needs_switching?
17
17
 
18
- Bundler.ui.info \
19
- "Bundler #{current_version} is running, but your lockfile was generated with #{lockfile_version}. " \
20
- "Installing Bundler #{lockfile_version} and restarting using that version."
21
-
22
18
  install_and_restart_with_locked_bundler
23
19
  end
24
20
 
@@ -26,8 +22,14 @@ module Bundler
26
22
 
27
23
  def install_and_restart_with_locked_bundler
28
24
  bundler_dep = Gem::Dependency.new("bundler", lockfile_version)
25
+ spec = fetch_spec_for(bundler_dep)
26
+ return if spec.nil?
27
+
28
+ Bundler.ui.info \
29
+ "Bundler #{current_version} is running, but your lockfile was generated with #{lockfile_version}. " \
30
+ "Installing Bundler #{lockfile_version} and restarting using that version."
29
31
 
30
- Gem.install(bundler_dep)
32
+ spec.source.install(spec)
31
33
  rescue StandardError => e
32
34
  Bundler.ui.trace e
33
35
  Bundler.ui.warn "There was an error installing the locked bundler version (#{lockfile_version}), rerun with the `--verbose` flag for more details. Going on using bundler #{current_version}."
@@ -35,14 +37,28 @@ module Bundler
35
37
  restart_with_locked_bundler
36
38
  end
37
39
 
40
+ def fetch_spec_for(bundler_dep)
41
+ source = Bundler::Source::Rubygems.new("remotes" => "https://rubygems.org")
42
+ source.remote!
43
+ source.add_dependency_names("bundler")
44
+ spec = source.specs.search(bundler_dep).first
45
+ if spec.nil?
46
+ Bundler.ui.warn "Your lockfile is locked to a version of bundler (#{lockfile_version}) that doesn't exist at https://rubygems.org/. Going on using #{current_version}"
47
+ end
48
+ spec
49
+ end
50
+
38
51
  def restart_with_locked_bundler
39
52
  configured_gem_home = ENV["GEM_HOME"]
40
53
  configured_gem_path = ENV["GEM_PATH"]
41
54
 
55
+ cmd = [$PROGRAM_NAME, *ARGV]
56
+ cmd.unshift(Gem.ruby) unless File.executable?($PROGRAM_NAME)
57
+
42
58
  Bundler.with_original_env do
43
59
  Kernel.exec(
44
60
  { "GEM_HOME" => configured_gem_home, "GEM_PATH" => configured_gem_path, "BUNDLER_VERSION" => lockfile_version },
45
- $PROGRAM_NAME, *ARGV
61
+ *cmd
46
62
  )
47
63
  end
48
64
  end
@@ -53,7 +69,12 @@ module Bundler
53
69
  SharedHelpers.in_bundle? &&
54
70
  lockfile_version &&
55
71
  !lockfile_version.end_with?(".dev") &&
56
- lockfile_version != current_version
72
+ lockfile_version != current_version &&
73
+ !updating?
74
+ end
75
+
76
+ def updating?
77
+ "update".start_with?(ARGV.first || " ") && ARGV[1..-1].any? {|a| a.start_with?("--bundler") }
57
78
  end
58
79
 
59
80
  def installed?
@@ -219,6 +219,7 @@ module Bundler
219
219
  def path
220
220
  configs.each do |_level, settings|
221
221
  path = value_for("path", settings)
222
+ path = "vendor/bundle" if value_for("deployment", settings) && path.nil?
222
223
  path_system = value_for("path.system", settings)
223
224
  disabled_shared_gems = value_for("disable_shared_gems", settings)
224
225
  next if path.nil? && path_system.nil? && disabled_shared_gems.nil?
@@ -210,9 +210,9 @@ class Bundler::Thor
210
210
  #
211
211
  # ==== Examples
212
212
  #
213
- # inject_into_class "app/controllers/application_controller.rb", ApplicationController, " filter_parameter :password\n"
213
+ # inject_into_class "app/controllers/application_controller.rb", "ApplicationController", " filter_parameter :password\n"
214
214
  #
215
- # inject_into_class "app/controllers/application_controller.rb", ApplicationController do
215
+ # inject_into_class "app/controllers/application_controller.rb", "ApplicationController" do
216
216
  # " filter_parameter :password\n"
217
217
  # end
218
218
  #
@@ -233,9 +233,9 @@ class Bundler::Thor
233
233
  #
234
234
  # ==== Examples
235
235
  #
236
- # inject_into_module "app/helpers/application_helper.rb", ApplicationHelper, " def help; 'help'; end\n"
236
+ # inject_into_module "app/helpers/application_helper.rb", "ApplicationHelper", " def help; 'help'; end\n"
237
237
  #
238
- # inject_into_module "app/helpers/application_helper.rb", ApplicationHelper do
238
+ # inject_into_module "app/helpers/application_helper.rb", "ApplicationHelper" do
239
239
  # " def help; 'help'; end\n"
240
240
  # end
241
241
  #
@@ -252,7 +252,7 @@ class Bundler::Thor
252
252
  # flag<Regexp|String>:: the regexp or string to be replaced
253
253
  # replacement<String>:: the replacement, can be also given as a block
254
254
  # config<Hash>:: give :verbose => false to not log the status, and
255
- # :force => true, to force the replacement regardless of runner behavior.
255
+ # :force => true, to force the replacement regardles of runner behavior.
256
256
  #
257
257
  # ==== Example
258
258
  #
@@ -331,7 +331,7 @@ class Bundler::Thor
331
331
  path = File.expand_path(path, destination_root)
332
332
 
333
333
  say_status :remove, relative_to_original_destination_root(path), config.fetch(:verbose, true)
334
- if !options[:pretend] && File.exist?(path)
334
+ if !options[:pretend] && (File.exist?(path) || File.symlink?(path))
335
335
  require "fileutils"
336
336
  ::FileUtils.rm_rf(path)
337
337
  end
@@ -106,12 +106,14 @@ class Bundler::Thor
106
106
  # Adds the content to the file.
107
107
  #
108
108
  def replace!(regexp, string, force)
109
- return if pretend?
110
109
  content = File.read(destination)
111
- if force || !content.include?(replacement)
110
+ before, after = content.split(regexp, 2)
111
+ snippet = (behavior == :after ? after : before).to_s
112
+
113
+ if force || !snippet.include?(replacement)
112
114
  success = content.gsub!(regexp, string)
113
115
 
114
- File.open(destination, "wb") { |file| file.write(content) }
116
+ File.open(destination, "wb") { |file| file.write(content) } unless pretend?
115
117
  success
116
118
  end
117
119
  end
@@ -161,6 +161,8 @@ class Bundler::Thor
161
161
  # to the block you provide. The path is set back to the previous path when
162
162
  # the method exits.
163
163
  #
164
+ # Returns the value yielded by the block.
165
+ #
164
166
  # ==== Parameters
165
167
  # dir<String>:: the directory to move to.
166
168
  # config<Hash>:: give :verbose => true to log and use padding.
@@ -179,16 +181,18 @@ class Bundler::Thor
179
181
  FileUtils.mkdir_p(destination_root)
180
182
  end
181
183
 
184
+ result = nil
182
185
  if pretend
183
186
  # In pretend mode, just yield down to the block
184
- block.arity == 1 ? yield(destination_root) : yield
187
+ result = block.arity == 1 ? yield(destination_root) : yield
185
188
  else
186
189
  require "fileutils"
187
- FileUtils.cd(destination_root) { block.arity == 1 ? yield(destination_root) : yield }
190
+ FileUtils.cd(destination_root) { result = block.arity == 1 ? yield(destination_root) : yield }
188
191
  end
189
192
 
190
193
  @destination_stack.pop
191
194
  shell.padding -= 1 if verbose
195
+ result
192
196
  end
193
197
 
194
198
  # Goes to the root and execute the given block.
@@ -28,6 +28,12 @@ class Bundler::Thor
28
28
  super(convert_key(key))
29
29
  end
30
30
 
31
+ def except(*keys)
32
+ dup.tap do |hash|
33
+ keys.each { |key| hash.delete(convert_key(key)) }
34
+ end
35
+ end
36
+
31
37
  def fetch(key, *args)
32
38
  super(convert_key(key), *args)
33
39
  end
@@ -102,9 +102,14 @@ class Bundler::Thor
102
102
  end
103
103
 
104
104
  if Correctable
105
- DidYouMean::SPELL_CHECKERS.merge!(
106
- 'Bundler::Thor::UndefinedCommandError' => UndefinedCommandError::SpellChecker,
107
- 'Bundler::Thor::UnknownArgumentError' => UnknownArgumentError::SpellChecker
108
- )
105
+ if DidYouMean.respond_to?(:correct_error)
106
+ DidYouMean.correct_error(Bundler::Thor::UndefinedCommandError, UndefinedCommandError::SpellChecker)
107
+ DidYouMean.correct_error(Bundler::Thor::UnknownArgumentError, UnknownArgumentError::SpellChecker)
108
+ else
109
+ DidYouMean::SPELL_CHECKERS.merge!(
110
+ 'Bundler::Thor::UndefinedCommandError' => UndefinedCommandError::SpellChecker,
111
+ 'Bundler::Thor::UnknownArgumentError' => UnknownArgumentError::SpellChecker
112
+ )
113
+ end
109
114
  end
110
115
  end
@@ -45,6 +45,7 @@ class Bundler::Thor
45
45
  @switches = {}
46
46
  @extra = []
47
47
  @stopped_parsing_after_extra_index = nil
48
+ @is_treated_as_value = false
48
49
 
49
50
  options.each do |option|
50
51
  @switches[option.switch_name] = option
@@ -74,8 +75,19 @@ class Bundler::Thor
74
75
  end
75
76
  end
76
77
 
78
+ def shift
79
+ @is_treated_as_value = false
80
+ super
81
+ end
82
+
83
+ def unshift(arg, is_value: false)
84
+ @is_treated_as_value = is_value
85
+ super(arg)
86
+ end
87
+
77
88
  def parse(args) # rubocop:disable MethodLength
78
89
  @pile = args.dup
90
+ @is_treated_as_value = false
79
91
  @parsing_options = true
80
92
 
81
93
  while peek
@@ -88,7 +100,10 @@ class Bundler::Thor
88
100
  when SHORT_SQ_RE
89
101
  unshift($1.split("").map { |f| "-#{f}" })
90
102
  next
91
- when EQ_RE, SHORT_NUM
103
+ when EQ_RE
104
+ unshift($2, is_value: true)
105
+ switch = $1
106
+ when SHORT_NUM
92
107
  unshift($2)
93
108
  switch = $1
94
109
  when LONG_RE, SHORT_RE
@@ -148,6 +163,7 @@ class Bundler::Thor
148
163
  # Two booleans are returned. The first is true if the current value
149
164
  # starts with a hyphen; the second is true if it is a registered switch.
150
165
  def current_is_switch?
166
+ return [false, false] if @is_treated_as_value
151
167
  case peek
152
168
  when LONG_RE, SHORT_RE, EQ_RE, SHORT_NUM
153
169
  [true, switch?($1)]
@@ -159,6 +175,7 @@ class Bundler::Thor
159
175
  end
160
176
 
161
177
  def current_is_switch_formatted?
178
+ return false if @is_treated_as_value
162
179
  case peek
163
180
  when LONG_RE, SHORT_RE, EQ_RE, SHORT_NUM, SHORT_SQ_RE
164
181
  true
@@ -168,6 +185,7 @@ class Bundler::Thor
168
185
  end
169
186
 
170
187
  def current_is_value?
188
+ return true if @is_treated_as_value
171
189
  peek && (!parsing_options? || super)
172
190
  end
173
191
 
@@ -103,6 +103,23 @@ class Bundler::Thor
103
103
  stdout.flush
104
104
  end
105
105
 
106
+ # Say (print) an error to the user. If the sentence ends with a whitespace
107
+ # or tab character, a new line is not appended (print + flush). Otherwise
108
+ # are passed straight to puts (behavior got from Highline).
109
+ #
110
+ # ==== Example
111
+ # say_error("error: something went wrong")
112
+ #
113
+ def say_error(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
114
+ return if quiet?
115
+
116
+ buffer = prepare_message(message, *color)
117
+ buffer << "\n" if force_new_line && !message.to_s.end_with?("\n")
118
+
119
+ stderr.print(buffer)
120
+ stderr.flush
121
+ end
122
+
106
123
  # Say a status with the given color and appends the message. Since this
107
124
  # method is used frequently by actions, it allows nil or false to be given
108
125
  # in log_status, avoiding the message from being shown. If a Symbol is
@@ -111,13 +128,14 @@ class Bundler::Thor
111
128
  def say_status(status, message, log_status = true)
112
129
  return if quiet? || log_status == false
113
130
  spaces = " " * (padding + 1)
114
- color = log_status.is_a?(Symbol) ? log_status : :green
115
-
116
131
  status = status.to_s.rjust(12)
132
+ margin = " " * status.length + spaces
133
+
134
+ color = log_status.is_a?(Symbol) ? log_status : :green
117
135
  status = set_color status, color, true if color
118
136
 
119
- buffer = "#{status}#{spaces}#{message}"
120
- buffer = "#{buffer}\n" unless buffer.end_with?("\n")
137
+ message = message.to_s.chomp.gsub(/(?<!\A)^/, margin)
138
+ buffer = "#{status}#{spaces}#{message}\n"
121
139
 
122
140
  stdout.print(buffer)
123
141
  stdout.flush
@@ -21,7 +21,7 @@ class Bundler::Thor
21
21
  end
22
22
 
23
23
  module Shell
24
- SHELL_DELEGATED_METHODS = [:ask, :error, :set_color, :yes?, :no?, :say, :say_status, :print_in_columns, :print_table, :print_wrapped, :file_collision, :terminal_width]
24
+ SHELL_DELEGATED_METHODS = [:ask, :error, :set_color, :yes?, :no?, :say, :say_error, :say_status, :print_in_columns, :print_table, :print_wrapped, :file_collision, :terminal_width]
25
25
  attr_writer :shell
26
26
 
27
27
  autoload :Basic, File.expand_path("shell/basic", __dir__)
@@ -211,7 +211,7 @@ class Bundler::Thor
211
211
  #
212
212
  def globs_for(path)
213
213
  path = escape_globs(path)
214
- ["#{path}/Thorfile", "#{path}/*.thor", "#{path}/tasks/*.thor", "#{path}/lib/tasks/*.thor"]
214
+ ["#{path}/Thorfile", "#{path}/*.thor", "#{path}/tasks/*.thor", "#{path}/lib/tasks/**/*.thor"]
215
215
  end
216
216
 
217
217
  # Return the path to the ruby interpreter taking into account multiple
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module Bundler
4
- VERSION = "2.3.0".freeze
4
+ VERSION = "2.3.4".freeze
5
5
 
6
6
  def self.bundler_major_version
7
7
  @bundler_major_version ||= VERSION.split(".").first.to_i
@@ -2,48 +2,18 @@
2
2
 
3
3
  module Gem::BundlerVersionFinder
4
4
  def self.bundler_version
5
- version, _ = bundler_version_with_reason
5
+ v = ENV["BUNDLER_VERSION"]
6
6
 
7
- return unless version
7
+ v ||= bundle_update_bundler_version
8
+ return if v == true
8
9
 
9
- Gem::Version.new(version)
10
- end
11
-
12
- def self.bundler_version_with_reason
13
- if v = ENV["BUNDLER_VERSION"]
14
- return [v, "`$BUNDLER_VERSION`"]
15
- end
16
- if v = bundle_update_bundler_version
17
- return if v == true
18
- return [v, "`bundle update --bundler`"]
19
- end
20
- v, lockfile = lockfile_version
21
- if v
22
- return [v, "your #{lockfile}"]
23
- end
24
- end
10
+ v ||= lockfile_version
11
+ return unless v
25
12
 
26
- def self.missing_version_message
27
- return unless vr = bundler_version_with_reason
28
- <<-EOS
29
- Could not find 'bundler' (#{vr.first}) required by #{vr.last}.
30
- To update to the latest version installed on your system, run `bundle update --bundler`.
31
- To install the missing version, run `gem install bundler:#{vr.first}`
32
- EOS
13
+ Gem::Version.new(v)
33
14
  end
34
15
 
35
- def self.compatible?(spec)
36
- return true unless spec.name == "bundler".freeze
37
- return true unless bundler_version = self.bundler_version
38
-
39
- spec.version.segments.first == bundler_version.segments.first
40
- end
41
-
42
- def self.filter!(specs)
43
- return unless bundler_version = self.bundler_version
44
-
45
- specs.reject! {|spec| spec.version.segments.first != bundler_version.segments.first }
46
-
16
+ def self.prioritize!(specs)
47
17
  exact_match_index = specs.find_index {|spec| spec.version == bundler_version }
48
18
  return unless exact_match_index
49
19
 
@@ -68,12 +38,10 @@ To install the missing version, run `gem install bundler:#{vr.first}`
68
38
  private_class_method :bundle_update_bundler_version
69
39
 
70
40
  def self.lockfile_version
71
- return unless lockfile = lockfile_contents
72
- lockfile, contents = lockfile
73
- lockfile ||= "lockfile"
41
+ return unless contents = lockfile_contents
74
42
  regexp = /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
75
43
  return unless contents =~ regexp
76
- [$1, lockfile]
44
+ $1
77
45
  end
78
46
  private_class_method :lockfile_version
79
47
 
@@ -103,7 +71,7 @@ To install the missing version, run `gem install bundler:#{vr.first}`
103
71
 
104
72
  return unless File.file?(lockfile)
105
73
 
106
- [lockfile, File.read(lockfile)]
74
+ File.read(lockfile)
107
75
  end
108
76
  private_class_method :lockfile_contents
109
77
  end
@@ -286,10 +286,11 @@ command to remove old versions.
286
286
 
287
287
  check_oldest_rubygems version
288
288
 
289
- update_gem 'rubygems-update', version
290
-
291
289
  installed_gems = Gem::Specification.find_all_by_name 'rubygems-update', requirement
292
- version = installed_gems.first.version
290
+ installed_gems = update_gem('rubygems-update', version) if installed_gems.empty?
291
+ return if installed_gems.empty?
292
+
293
+ version = installed_gems.first.version
293
294
 
294
295
  install_rubygems version
295
296
  end
@@ -277,7 +277,7 @@ class Gem::Dependency
277
277
  requirement.satisfied_by?(spec.version) && env_req.satisfied_by?(spec.version)
278
278
  end.map(&:to_spec)
279
279
 
280
- Gem::BundlerVersionFinder.filter!(matches) if filters_bundler?
280
+ Gem::BundlerVersionFinder.prioritize!(matches) if prioritizes_bundler?
281
281
 
282
282
  if platform_only
283
283
  matches.reject! do |spec|
@@ -295,7 +295,7 @@ class Gem::Dependency
295
295
  @requirement.specific?
296
296
  end
297
297
 
298
- def filters_bundler?
298
+ def prioritizes_bundler?
299
299
  name == "bundler".freeze && !specific?
300
300
  end
301
301
 
@@ -325,11 +325,11 @@ class Gem::Dependency
325
325
  active = matches.find {|spec| spec.activated? }
326
326
  return active if active
327
327
 
328
- return matches.first if prerelease?
329
-
330
- # Move prereleases to the end of the list for >= 0 requirements
331
- pre, matches = matches.partition {|spec| spec.version.prerelease? }
332
- matches += pre if requirement == Gem::Requirement.default
328
+ unless prerelease?
329
+ # Move prereleases to the end of the list for >= 0 requirements
330
+ pre, matches = matches.partition {|spec| spec.version.prerelease? }
331
+ matches += pre if requirement == Gem::Requirement.default
332
+ end
333
333
 
334
334
  matches.first
335
335
  end
@@ -59,9 +59,6 @@ module Gem
59
59
  private
60
60
 
61
61
  def build_message
62
- if name == "bundler" && message = Gem::BundlerVersionFinder.missing_version_message
63
- return message
64
- end
65
62
  names = specs.map(&:full_name)
66
63
  "Could not find '#{name}' (#{requirement}) - did find: [#{names.join ','}]\n"
67
64
  end