bundler 2.6.9 → 2.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1136 -1033
  3. data/README.md +7 -7
  4. data/bundler.gemspec +2 -2
  5. data/lib/bundler/build_metadata.rb +10 -11
  6. data/lib/bundler/checksum.rb +6 -0
  7. data/lib/bundler/cli/cache.rb +0 -1
  8. data/lib/bundler/cli/common.rb +1 -1
  9. data/lib/bundler/cli/config.rb +2 -2
  10. data/lib/bundler/cli/gem.rb +62 -30
  11. data/lib/bundler/cli/install.rb +5 -7
  12. data/lib/bundler/cli/lock.rb +5 -5
  13. data/lib/bundler/cli/outdated.rb +1 -1
  14. data/lib/bundler/cli/show.rb +2 -6
  15. data/lib/bundler/cli/update.rb +3 -3
  16. data/lib/bundler/cli.rb +45 -49
  17. data/lib/bundler/compact_index_client.rb +1 -5
  18. data/lib/bundler/current_ruby.rb +27 -3
  19. data/lib/bundler/definition.rb +97 -81
  20. data/lib/bundler/dependency.rb +1 -1
  21. data/lib/bundler/dsl.rb +34 -24
  22. data/lib/bundler/feature_flag.rb +15 -12
  23. data/lib/bundler/fetcher/dependency.rb +2 -1
  24. data/lib/bundler/fetcher/downloader.rb +33 -7
  25. data/lib/bundler/fetcher.rb +49 -19
  26. data/lib/bundler/friendly_errors.rb +2 -1
  27. data/lib/bundler/index.rb +7 -2
  28. data/lib/bundler/installer.rb +5 -4
  29. data/lib/bundler/lazy_specification.rb +9 -7
  30. data/lib/bundler/lockfile_parser.rb +21 -5
  31. data/lib/bundler/man/bundle-add.1 +1 -1
  32. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  33. data/lib/bundler/man/bundle-cache.1 +1 -1
  34. data/lib/bundler/man/bundle-check.1 +1 -1
  35. data/lib/bundler/man/bundle-clean.1 +1 -1
  36. data/lib/bundler/man/bundle-config.1 +200 -137
  37. data/lib/bundler/man/bundle-config.1.ronn +138 -109
  38. data/lib/bundler/man/bundle-console.1 +1 -1
  39. data/lib/bundler/man/bundle-doctor.1 +43 -4
  40. data/lib/bundler/man/bundle-doctor.1.ronn +48 -4
  41. data/lib/bundler/man/bundle-env.1 +1 -1
  42. data/lib/bundler/man/bundle-exec.1 +1 -1
  43. data/lib/bundler/man/bundle-fund.1 +1 -1
  44. data/lib/bundler/man/bundle-gem.1 +67 -44
  45. data/lib/bundler/man/bundle-gem.1.ronn +8 -4
  46. data/lib/bundler/man/bundle-help.1 +1 -1
  47. data/lib/bundler/man/bundle-info.1 +1 -1
  48. data/lib/bundler/man/bundle-init.1 +1 -1
  49. data/lib/bundler/man/bundle-inject.1 +2 -2
  50. data/lib/bundler/man/bundle-inject.1.ronn +1 -1
  51. data/lib/bundler/man/bundle-install.1 +4 -4
  52. data/lib/bundler/man/bundle-install.1.ronn +3 -4
  53. data/lib/bundler/man/bundle-issue.1 +1 -1
  54. data/lib/bundler/man/bundle-licenses.1 +1 -1
  55. data/lib/bundler/man/bundle-list.1 +1 -1
  56. data/lib/bundler/man/bundle-lock.1 +1 -1
  57. data/lib/bundler/man/bundle-open.1 +1 -1
  58. data/lib/bundler/man/bundle-outdated.1 +1 -1
  59. data/lib/bundler/man/bundle-platform.1 +1 -1
  60. data/lib/bundler/man/bundle-plugin.1 +40 -15
  61. data/lib/bundler/man/bundle-plugin.1.ronn +44 -15
  62. data/lib/bundler/man/bundle-pristine.1 +1 -1
  63. data/lib/bundler/man/bundle-remove.1 +1 -1
  64. data/lib/bundler/man/bundle-show.1 +1 -1
  65. data/lib/bundler/man/bundle-update.1 +5 -5
  66. data/lib/bundler/man/bundle-update.1.ronn +4 -4
  67. data/lib/bundler/man/bundle-version.1 +1 -1
  68. data/lib/bundler/man/bundle-viz.1 +1 -1
  69. data/lib/bundler/man/bundle.1 +1 -1
  70. data/lib/bundler/man/gemfile.5 +1 -1
  71. data/lib/bundler/match_platform.rb +31 -12
  72. data/lib/bundler/materialization.rb +2 -2
  73. data/lib/bundler/resolver/package.rb +2 -1
  74. data/lib/bundler/resolver.rb +1 -3
  75. data/lib/bundler/rubygems_ext.rb +116 -120
  76. data/lib/bundler/rubygems_integration.rb +11 -6
  77. data/lib/bundler/runtime.rb +1 -1
  78. data/lib/bundler/self_manager.rb +32 -42
  79. data/lib/bundler/settings/validator.rb +0 -23
  80. data/lib/bundler/settings.rb +4 -6
  81. data/lib/bundler/shared_helpers.rb +6 -4
  82. data/lib/bundler/source/gemspec.rb +4 -0
  83. data/lib/bundler/source/git/git_proxy.rb +3 -3
  84. data/lib/bundler/source/path.rb +9 -0
  85. data/lib/bundler/source_list.rb +1 -5
  86. data/lib/bundler/source_map.rb +1 -1
  87. data/lib/bundler/spec_set.rb +7 -3
  88. data/lib/bundler/templates/Executable +0 -11
  89. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +2 -0
  90. data/lib/bundler/templates/newgem/newgem.gemspec.tt +6 -5
  91. data/lib/bundler/ui/shell.rb +2 -2
  92. data/lib/bundler/vendor/net-http-persistent/README.rdoc +1 -1
  93. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +2 -1
  94. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +81 -42
  95. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +42 -6
  96. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +1 -1
  97. data/lib/bundler/vendor/thor/lib/thor/runner.rb +1 -1
  98. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +3 -7
  99. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  100. data/lib/bundler/version.rb +10 -2
  101. data/lib/bundler/worker.rb +1 -1
  102. data/lib/bundler.rb +14 -12
  103. metadata +4 -14
  104. data/lib/bundler/gem_helpers.rb +0 -144
  105. data/lib/bundler/templates/Executable.bundler +0 -109
  106. data/lib/bundler/vendor/connection_pool/.document +0 -1
  107. data/lib/bundler/vendor/fileutils/.document +0 -1
  108. data/lib/bundler/vendor/net-http-persistent/.document +0 -1
  109. data/lib/bundler/vendor/pub_grub/.document +0 -1
  110. data/lib/bundler/vendor/securerandom/.document +0 -1
  111. data/lib/bundler/vendor/thor/.document +0 -1
  112. data/lib/bundler/vendor/tsort/.document +0 -1
  113. data/lib/bundler/vendor/uri/.document +0 -1
@@ -8,12 +8,10 @@ module Bundler
8
8
 
9
9
  BOOL_KEYS = %w[
10
10
  allow_offline_install
11
- auto_clean_without_path
12
11
  auto_install
13
12
  cache_all
14
13
  cache_all_platforms
15
14
  clean
16
- default_install_uses_path
17
15
  deployment
18
16
  disable_checksum_validation
19
17
  disable_exec_load
@@ -27,6 +25,7 @@ module Bundler
27
25
  gem.changelog
28
26
  gem.coc
29
27
  gem.mit
28
+ gem.bundle
30
29
  git.allow_insecure
31
30
  global_gem_cache
32
31
  ignore_messages
@@ -35,15 +34,13 @@ module Bundler
35
34
  lockfile_checksums
36
35
  no_install
37
36
  no_prune
38
- path_relative_to_cwd
39
37
  path.system
40
38
  plugins
41
39
  prefer_patch
42
- print_only_version_number
43
- setup_makes_kernel_gem_public
44
40
  silence_deprecations
45
41
  silence_root_warning
46
42
  update_requires_all_flag
43
+ verbose
47
44
  ].freeze
48
45
 
49
46
  REMEMBERED_KEYS = %w[
@@ -86,6 +83,7 @@ module Bundler
86
83
  gemfile
87
84
  path
88
85
  shebang
86
+ simulate_version
89
87
  system_bindir
90
88
  trust-policy
91
89
  version
@@ -274,7 +272,7 @@ module Bundler
274
272
  def use_system_gems?
275
273
  return true if system_path
276
274
  return false if explicit_path
277
- !Bundler.feature_flag.default_install_uses_path?
275
+ !Bundler.feature_flag.bundler_5_mode?
278
276
  end
279
277
 
280
278
  def base_path
@@ -133,13 +133,16 @@ module Bundler
133
133
  removed_message += suffix if removed_message
134
134
  end
135
135
 
136
- bundler_major_version = Bundler.bundler_major_version
137
- if bundler_major_version > major_version
136
+ require_relative "../bundler"
137
+
138
+ feature_flag = Bundler.feature_flag
139
+
140
+ if feature_flag.removed_major?(major_version)
138
141
  require_relative "errors"
139
142
  raise DeprecatedError, "[REMOVED] #{removed_message || message}"
140
143
  end
141
144
 
142
- return unless bundler_major_version >= major_version && prints_major_deprecations?
145
+ return unless feature_flag.deprecated_major?(major_version) && prints_major_deprecations?
143
146
  Bundler.ui.warn("[DEPRECATED] #{message}")
144
147
  end
145
148
 
@@ -386,7 +389,6 @@ module Bundler
386
389
  end
387
390
 
388
391
  def prints_major_deprecations?
389
- require_relative "../bundler"
390
392
  return false if Bundler.settings[:silence_deprecations]
391
393
  require_relative "deprecate"
392
394
  return false if Bundler::Deprecate.skip
@@ -10,6 +10,10 @@ module Bundler
10
10
  super
11
11
  @gemspec = options["gemspec"]
12
12
  end
13
+
14
+ def to_s
15
+ "gemspec at `#{@path}`"
16
+ end
13
17
  end
14
18
  end
15
19
  end
@@ -305,8 +305,8 @@ module Bundler
305
305
  end
306
306
 
307
307
  def has_revision_cached?
308
- return unless @revision && path.exist?
309
- git("cat-file", "-e", @revision, dir: path)
308
+ return unless commit && path.exist?
309
+ git("cat-file", "-e", commit, dir: path)
310
310
  true
311
311
  rescue GitError
312
312
  false
@@ -408,7 +408,7 @@ module Bundler
408
408
  def capture3_args_for(cmd, dir)
409
409
  return ["git", *cmd] unless dir
410
410
 
411
- if Bundler.feature_flag.bundler_3_mode? || supports_minus_c?
411
+ if Bundler.feature_flag.bundler_4_mode? || supports_minus_c?
412
412
  ["git", "-C", dir.to_s, *cmd]
413
413
  else
414
414
  ["git", *cmd, { chdir: dir.to_s }]
@@ -53,6 +53,8 @@ module Bundler
53
53
  "source at `#{@path}`"
54
54
  end
55
55
 
56
+ alias_method :identifier, :to_s
57
+
56
58
  alias_method :to_gemfile, :path
57
59
 
58
60
  def hash
@@ -167,6 +169,13 @@ module Bundler
167
169
  next unless spec = load_gemspec(file)
168
170
  spec.source = self
169
171
 
172
+ # The ignore attribute is for ignoring installed gems that don't
173
+ # have extensions correctly compiled for activation. In the case of
174
+ # path sources, there's a single version of each gem in the path
175
+ # source available to Bundler, so we always certainly want to
176
+ # consider that for activation and never makes sense to ignore it.
177
+ spec.ignored = false
178
+
170
179
  # Validation causes extension_dir to be calculated, which depends
171
180
  # on #source, so we validate here instead of load_gemspec
172
181
  validate_spec(spec)
@@ -103,7 +103,7 @@ module Bundler
103
103
  end
104
104
 
105
105
  def get(source)
106
- source_list_for(source).find {|s| equivalent_source?(source, s) }
106
+ source_list_for(source).find {|s| s.include?(source) }
107
107
  end
108
108
 
109
109
  def lock_sources
@@ -265,9 +265,5 @@ module Bundler
265
265
  def equivalent_sources?(lock_sources, replacement_sources)
266
266
  lock_sources.sort_by(&:identifier) == replacement_sources.sort_by(&:identifier)
267
267
  end
268
-
269
- def equivalent_source?(source, other_source)
270
- source == other_source
271
- end
272
268
  end
273
269
  end
@@ -23,7 +23,7 @@ module Bundler
23
23
  if previous_source.nil?
24
24
  requirements[indirect_dependency_name] = source
25
25
  else
26
- no_ambiguous_sources = Bundler.feature_flag.bundler_3_mode?
26
+ no_ambiguous_sources = Bundler.feature_flag.bundler_4_mode?
27
27
 
28
28
  msg = ["The gem '#{indirect_dependency_name}' was found in multiple relevant sources."]
29
29
  msg.concat [previous_source, source].map {|s| " * #{s}" }.sort
@@ -76,7 +76,7 @@ module Bundler
76
76
 
77
77
  new_platforms = all_platforms.select do |platform|
78
78
  next if platforms.include?(platform)
79
- next unless GemHelpers.generic(platform) == Gem::Platform::RUBY
79
+ next unless Gem::Platform.generic(platform) == Gem::Platform::RUBY
80
80
 
81
81
  complete_platform(platform)
82
82
  end
@@ -179,11 +179,13 @@ module Bundler
179
179
  end
180
180
 
181
181
  def -(other)
182
+ SharedHelpers.major_deprecation 2, "SpecSet#- has been removed with no replacement"
183
+
182
184
  SpecSet.new(to_a - other.to_a)
183
185
  end
184
186
 
185
187
  def find_by_name_and_platform(name, platform)
186
- @specs.detect {|spec| spec.name == name && spec.match_platform(platform) }
188
+ @specs.detect {|spec| spec.name == name && spec.installable_on_platform?(platform) }
187
189
  end
188
190
 
189
191
  def specs_with_additional_variants_from(other)
@@ -210,6 +212,8 @@ module Bundler
210
212
  end
211
213
 
212
214
  def <<(spec)
215
+ SharedHelpers.major_deprecation 2, "SpecSet#<< has been removed with no replacement"
216
+
213
217
  @specs << spec
214
218
  end
215
219
 
@@ -280,7 +284,7 @@ module Bundler
280
284
  valid_platform = lookup.all? do |_, specs|
281
285
  spec = specs.first
282
286
  matching_specs = spec.source.specs.search([spec.name, spec.version])
283
- platform_spec = GemHelpers.select_best_platform_match(matching_specs, platform).find do |s|
287
+ platform_spec = MatchPlatform.select_best_platform_match(matching_specs, platform).find do |s|
284
288
  valid?(s)
285
289
  end
286
290
 
@@ -10,17 +10,6 @@
10
10
 
11
11
  ENV["BUNDLE_GEMFILE"] ||= File.expand_path("<%= relative_gemfile_path %>", __dir__)
12
12
 
13
- bundle_binstub = File.expand_path("bundle", __dir__)
14
-
15
- if File.file?(bundle_binstub)
16
- if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
17
- load(bundle_binstub)
18
- else
19
- abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
20
- Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21
- end
22
- end
23
-
24
13
  require "rubygems"
25
14
  require "bundler/setup"
26
15
 
@@ -18,6 +18,8 @@ jobs:
18
18
 
19
19
  steps:
20
20
  - uses: actions/checkout@v4
21
+ with:
22
+ persist-credentials: false
21
23
  <%- if config[:ext] == 'rust' -%>
22
24
  - name: Set up Ruby & Rust
23
25
  uses: oxidize-rb/actions/setup-ruby-and-rust@v1
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
 
11
11
  spec.summary = "TODO: Write a short summary, because RubyGems requires one."
12
12
  spec.description = "TODO: Write a longer description or delete this line."
13
- spec.homepage = "TODO: Put your gem's website or public repo URL here."
13
+ spec.homepage = "<%= config[:homepage_uri] %>"
14
14
  <%- if config[:mit] -%>
15
15
  spec.license = "MIT"
16
16
  <%- end -%>
@@ -20,10 +20,11 @@ Gem::Specification.new do |spec|
20
20
  <%- end -%>
21
21
 
22
22
  spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
23
-
24
23
  spec.metadata["homepage_uri"] = spec.homepage
25
- spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
26
- spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
24
+ spec.metadata["source_code_uri"] = "<%= config[:source_code_uri] %>"
25
+ <%- if config[:changelog] -%>
26
+ spec.metadata["changelog_uri"] = "<%= config[:changelog_uri] %>"
27
+ <%- end -%>
27
28
 
28
29
  # Specify which files should be added to the gem when it is released.
29
30
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -31,7 +32,7 @@ Gem::Specification.new do |spec|
31
32
  spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls|
32
33
  ls.readlines("\x0", chomp: true).reject do |f|
33
34
  (f == gemspec) ||
34
- f.start_with?(*%w[bin/ test/ spec/ features/ .git <%= config[:ci_config_path] %>appveyor Gemfile])
35
+ f.start_with?(*%w[<%= config[:ignore_paths].join(" ") %>])
35
36
  end
36
37
  end
37
38
  spec.bindir = "exe"
@@ -80,11 +80,11 @@ module Bundler
80
80
  end
81
81
 
82
82
  def ask(msg)
83
- @shell.ask(msg)
83
+ @shell.ask(msg, :green)
84
84
  end
85
85
 
86
86
  def yes?(msg)
87
- @shell.yes?(msg)
87
+ @shell.yes?(msg, :green)
88
88
  end
89
89
 
90
90
  def no?(msg)
@@ -1,7 +1,7 @@
1
1
  = net-http-persistent
2
2
 
3
3
  home :: https://github.com/drbrain/net-http-persistent
4
- rdoc :: https://rdoc.info/gems/net-http-persistent
4
+ rdoc :: https://rubydoc.info/gems/net-http-persistent
5
5
 
6
6
  == DESCRIPTION:
7
7
 
@@ -63,7 +63,8 @@ class Gem::Net::HTTP::Persistent::TimedStackMulti < Bundler::ConnectionPool::Tim
63
63
  if @created >= @max && @enqueued >= 1
64
64
  oldest, = @lru.first
65
65
  @lru.delete oldest
66
- @ques[oldest].pop
66
+ connection = @ques[oldest].pop
67
+ connection.close if connection.respond_to?(:close)
67
68
 
68
69
  @created -= 1
69
70
  end
@@ -1,6 +1,7 @@
1
1
  require_relative '../../../../../vendored_net_http'
2
2
  require_relative '../../../../../vendored_uri'
3
- require 'cgi' # for escaping
3
+ require 'cgi/escape'
4
+ require 'cgi/util' unless defined?(CGI::EscapeExt)
4
5
  require_relative '../../../../connection_pool/lib/connection_pool'
5
6
 
6
7
  autoload :OpenSSL, 'openssl'
@@ -42,9 +43,8 @@ autoload :OpenSSL, 'openssl'
42
43
  # # perform the POST, the Gem::URI is always required
43
44
  # response http.request post_uri, post
44
45
  #
45
- # Note that for GET, HEAD and other requests that do not have a body you want
46
- # to use Gem::URI#request_uri not Gem::URI#path. The request_uri contains the query
47
- # params which are sent in the body for other requests.
46
+ # Note that for GET, HEAD and other requests that do not have a body,
47
+ # it uses Gem::URI#request_uri as default to send query params
48
48
  #
49
49
  # == TLS/SSL
50
50
  #
@@ -60,6 +60,7 @@ autoload :OpenSSL, 'openssl'
60
60
  # #ca_path :: Directory with certificate-authorities
61
61
  # #cert_store :: An SSL certificate store
62
62
  # #ciphers :: List of SSl ciphers allowed
63
+ # #extra_chain_cert :: Extra certificates to be added to the certificate chain
63
64
  # #private_key :: The client's SSL private key
64
65
  # #reuse_ssl_sessions :: Reuse a previously opened SSL session for a new
65
66
  # connection
@@ -176,7 +177,7 @@ class Gem::Net::HTTP::Persistent
176
177
  ##
177
178
  # The version of Gem::Net::HTTP::Persistent you are using
178
179
 
179
- VERSION = '4.0.4'
180
+ VERSION = '4.0.6'
180
181
 
181
182
  ##
182
183
  # Error class for errors raised by Gem::Net::HTTP::Persistent. Various
@@ -267,6 +268,11 @@ class Gem::Net::HTTP::Persistent
267
268
 
268
269
  attr_reader :ciphers
269
270
 
271
+ ##
272
+ # Extra certificates to be added to the certificate chain
273
+
274
+ attr_reader :extra_chain_cert
275
+
270
276
  ##
271
277
  # Sends debug_output to this IO via Gem::Net::HTTP#set_debug_output.
272
278
  #
@@ -587,6 +593,21 @@ class Gem::Net::HTTP::Persistent
587
593
  reconnect_ssl
588
594
  end
589
595
 
596
+ if Gem::Net::HTTP.method_defined?(:extra_chain_cert=)
597
+ ##
598
+ # Extra certificates to be added to the certificate chain.
599
+ # It is only supported starting from Gem::Net::HTTP version 0.1.1
600
+ def extra_chain_cert= extra_chain_cert
601
+ @extra_chain_cert = extra_chain_cert
602
+
603
+ reconnect_ssl
604
+ end
605
+ else
606
+ def extra_chain_cert= _extra_chain_cert
607
+ raise "extra_chain_cert= is not supported by this version of Gem::Net::HTTP"
608
+ end
609
+ end
610
+
590
611
  ##
591
612
  # Creates a new connection for +uri+
592
613
 
@@ -605,47 +626,49 @@ class Gem::Net::HTTP::Persistent
605
626
 
606
627
  connection = @pool.checkout net_http_args
607
628
 
608
- http = connection.http
629
+ begin
630
+ http = connection.http
609
631
 
610
- connection.ressl @ssl_generation if
611
- connection.ssl_generation != @ssl_generation
632
+ connection.ressl @ssl_generation if
633
+ connection.ssl_generation != @ssl_generation
612
634
 
613
- if not http.started? then
614
- ssl http if use_ssl
615
- start http
616
- elsif expired? connection then
617
- reset connection
618
- end
635
+ if not http.started? then
636
+ ssl http if use_ssl
637
+ start http
638
+ elsif expired? connection then
639
+ reset connection
640
+ end
619
641
 
620
- http.keep_alive_timeout = @idle_timeout if @idle_timeout
621
- http.max_retries = @max_retries if http.respond_to?(:max_retries=)
622
- http.read_timeout = @read_timeout if @read_timeout
623
- http.write_timeout = @write_timeout if
624
- @write_timeout && http.respond_to?(:write_timeout=)
642
+ http.keep_alive_timeout = @idle_timeout if @idle_timeout
643
+ http.max_retries = @max_retries if http.respond_to?(:max_retries=)
644
+ http.read_timeout = @read_timeout if @read_timeout
645
+ http.write_timeout = @write_timeout if
646
+ @write_timeout && http.respond_to?(:write_timeout=)
647
+
648
+ return yield connection
649
+ rescue Errno::ECONNREFUSED
650
+ if http.proxy?
651
+ address = http.proxy_address
652
+ port = http.proxy_port
653
+ else
654
+ address = http.address
655
+ port = http.port
656
+ end
625
657
 
626
- return yield connection
627
- rescue Errno::ECONNREFUSED
628
- if http.proxy?
629
- address = http.proxy_address
630
- port = http.proxy_port
631
- else
632
- address = http.address
633
- port = http.port
634
- end
658
+ raise Error, "connection refused: #{address}:#{port}"
659
+ rescue Errno::EHOSTDOWN
660
+ if http.proxy?
661
+ address = http.proxy_address
662
+ port = http.proxy_port
663
+ else
664
+ address = http.address
665
+ port = http.port
666
+ end
635
667
 
636
- raise Error, "connection refused: #{address}:#{port}"
637
- rescue Errno::EHOSTDOWN
638
- if http.proxy?
639
- address = http.proxy_address
640
- port = http.proxy_port
641
- else
642
- address = http.address
643
- port = http.port
668
+ raise Error, "host down: #{address}:#{port}"
669
+ ensure
670
+ @pool.checkin net_http_args
644
671
  end
645
-
646
- raise Error, "host down: #{address}:#{port}"
647
- ensure
648
- @pool.checkin net_http_args
649
672
  end
650
673
 
651
674
  ##
@@ -782,7 +805,7 @@ class Gem::Net::HTTP::Persistent
782
805
  @proxy_connection_id = [nil, *@proxy_args].join ':'
783
806
 
784
807
  if @proxy_uri.query then
785
- @no_proxy = CGI.parse(@proxy_uri.query)['no_proxy'].join(',').downcase.split(',').map { |x| x.strip }.reject { |x| x.empty? }
808
+ @no_proxy = Gem::URI.decode_www_form(@proxy_uri.query).filter_map { |k, v| v if k == 'no_proxy' }.join(',').downcase.split(',').map { |x| x.strip }.reject { |x| x.empty? }
786
809
  end
787
810
  end
788
811
 
@@ -953,7 +976,8 @@ class Gem::Net::HTTP::Persistent
953
976
  end
954
977
 
955
978
  ##
956
- # Shuts down all connections
979
+ # Shuts down all connections. Attempting to checkout a connection after
980
+ # shutdown will raise an error.
957
981
  #
958
982
  # *NOTE*: Calling shutdown for can be dangerous!
959
983
  #
@@ -964,6 +988,17 @@ class Gem::Net::HTTP::Persistent
964
988
  @pool.shutdown { |http| http.finish }
965
989
  end
966
990
 
991
+ ##
992
+ # Discard all existing connections. Subsequent checkouts will create
993
+ # new connections as needed.
994
+ #
995
+ # If any thread is still using a connection it may cause an error! Call
996
+ # #reload when you are completely done making requests!
997
+
998
+ def reload
999
+ @pool.reload { |http| http.finish }
1000
+ end
1001
+
967
1002
  ##
968
1003
  # Enables SSL on +connection+
969
1004
 
@@ -1021,6 +1056,10 @@ application:
1021
1056
  connection.key = @private_key
1022
1057
  end
1023
1058
 
1059
+ if defined?(@extra_chain_cert) and @extra_chain_cert
1060
+ connection.extra_chain_cert = @extra_chain_cert
1061
+ end
1062
+
1024
1063
  connection.cert_store = if @cert_store then
1025
1064
  @cert_store
1026
1065
  else
@@ -242,6 +242,35 @@ class Bundler::Thor
242
242
  insert_into_file(path, *(args << config), &block)
243
243
  end
244
244
 
245
+ # Run a regular expression replacement on a file, raising an error if the
246
+ # contents of the file are not changed.
247
+ #
248
+ # ==== Parameters
249
+ # path<String>:: path of the file to be changed
250
+ # flag<Regexp|String>:: the regexp or string to be replaced
251
+ # replacement<String>:: the replacement, can be also given as a block
252
+ # config<Hash>:: give :verbose => false to not log the status, and
253
+ # :force => true, to force the replacement regardless of runner behavior.
254
+ #
255
+ # ==== Example
256
+ #
257
+ # gsub_file! 'app/controllers/application_controller.rb', /#\s*(filter_parameter_logging :password)/, '\1'
258
+ #
259
+ # gsub_file! 'README', /rake/, :green do |match|
260
+ # match << " no more. Use thor!"
261
+ # end
262
+ #
263
+ def gsub_file!(path, flag, *args, &block)
264
+ config = args.last.is_a?(Hash) ? args.pop : {}
265
+
266
+ return unless behavior == :invoke || config.fetch(:force, false)
267
+
268
+ path = File.expand_path(path, destination_root)
269
+ say_status :gsub, relative_to_original_destination_root(path), config.fetch(:verbose, true)
270
+
271
+ actually_gsub_file(path, flag, args, true, &block) unless options[:pretend]
272
+ end
273
+
245
274
  # Run a regular expression replacement on a file.
246
275
  #
247
276
  # ==== Parameters
@@ -267,11 +296,7 @@ class Bundler::Thor
267
296
  path = File.expand_path(path, destination_root)
268
297
  say_status :gsub, relative_to_original_destination_root(path), config.fetch(:verbose, true)
269
298
 
270
- unless options[:pretend]
271
- content = File.binread(path)
272
- content.gsub!(flag, *args, &block)
273
- File.open(path, "wb") { |file| file.write(content) }
274
- end
299
+ actually_gsub_file(path, flag, args, false, &block) unless options[:pretend]
275
300
  end
276
301
 
277
302
  # Uncomment all lines matching a given regex. Preserves indentation before
@@ -348,7 +373,7 @@ class Bundler::Thor
348
373
  end
349
374
 
350
375
  def with_output_buffer(buf = "".dup) #:nodoc:
351
- raise ArgumentError, "Buffer can not be a frozen object" if buf.frozen?
376
+ raise ArgumentError, "Buffer cannot be a frozen object" if buf.frozen?
352
377
  old_buffer = output_buffer
353
378
  self.output_buffer = buf
354
379
  yield
@@ -357,6 +382,17 @@ class Bundler::Thor
357
382
  self.output_buffer = old_buffer
358
383
  end
359
384
 
385
+ def actually_gsub_file(path, flag, args, error_on_no_change, &block)
386
+ content = File.binread(path)
387
+ success = content.gsub!(flag, *args, &block)
388
+
389
+ if success.nil? && error_on_no_change
390
+ raise Bundler::Thor::Error, "The content of #{path} did not change"
391
+ end
392
+
393
+ File.open(path, "wb") { |file| file.write(content) }
394
+ end
395
+
360
396
  # Bundler::Thor::Actions#capture depends on what kind of buffer is used in ERB.
361
397
  # Thus CapturableERB fixes ERB to use String buffer.
362
398
  class CapturableERB < ERB
@@ -144,7 +144,7 @@ class Bundler::Thor
144
144
  def check_exclusive!
145
145
  opts = @assigns.keys
146
146
  # When option A and B are exclusive, if A and B are given at the same time,
147
- # the diffrence of argument array size will decrease.
147
+ # the difference of argument array size will decrease.
148
148
  found = @exclusives.find{ |ex| (ex - opts).size < ex.size - 1 }
149
149
  if found
150
150
  names = names_to_switch_names(found & opts).map{|n| "'#{n}'"}
@@ -1,7 +1,6 @@
1
1
  require_relative "../thor"
2
2
  require_relative "group"
3
3
 
4
- require "yaml"
5
4
  require "digest/sha2"
6
5
  require "pathname"
7
6
 
@@ -195,6 +194,7 @@ private
195
194
  def thor_yaml
196
195
  @thor_yaml ||= begin
197
196
  yaml_file = File.join(thor_root, "thor.yml")
197
+ require "yaml"
198
198
  yaml = YAML.load_file(yaml_file) if File.exist?(yaml_file)
199
199
  yaml || {}
200
200
  end
@@ -314,7 +314,7 @@ class Bundler::Thor
314
314
  diff_cmd = ENV["THOR_DIFF"] || ENV["RAILS_DIFF"] || "diff -u"
315
315
 
316
316
  require "tempfile"
317
- Tempfile.open(File.basename(destination), File.dirname(destination)) do |temp|
317
+ Tempfile.open(File.basename(destination), File.dirname(destination), binmode: true) do |temp|
318
318
  temp.write content
319
319
  temp.rewind
320
320
  system %(#{diff_cmd} "#{destination}" "#{temp.path}")
@@ -372,16 +372,12 @@ class Bundler::Thor
372
372
  Tempfile.open([File.basename(destination), File.extname(destination)], File.dirname(destination)) do |temp|
373
373
  temp.write content
374
374
  temp.rewind
375
- system %(#{merge_tool} "#{temp.path}" "#{destination}")
375
+ system(merge_tool, temp.path, destination)
376
376
  end
377
377
  end
378
378
 
379
379
  def merge_tool #:nodoc:
380
- @merge_tool ||= ENV["THOR_MERGE"] || git_merge_tool
381
- end
382
-
383
- def git_merge_tool #:nodoc:
384
- `git config merge.tool`.rstrip rescue ""
380
+ @merge_tool ||= ENV["THOR_MERGE"] || "git difftool --no-index"
385
381
  end
386
382
  end
387
383
  end
@@ -1,3 +1,3 @@
1
1
  class Bundler::Thor
2
- VERSION = "1.3.2"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -1,13 +1,21 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module Bundler
4
- VERSION = "2.6.9".freeze
4
+ VERSION = "2.7.2".freeze
5
5
 
6
6
  def self.bundler_major_version
7
- @bundler_major_version ||= VERSION.split(".").first.to_i
7
+ @bundler_major_version ||= gem_version.segments.first
8
8
  end
9
9
 
10
10
  def self.gem_version
11
11
  @gem_version ||= Gem::Version.create(VERSION)
12
12
  end
13
+
14
+ def self.verbose_version
15
+ @verbose_version ||= "#{VERSION}#{simulated_version ? " (simulating Bundler #{simulated_version})" : ""}"
16
+ end
17
+
18
+ def self.simulated_version
19
+ @simulated_version ||= Bundler.settings[:simulate_version]
20
+ end
13
21
  end