bundler 2.2.11 → 2.3.26

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 (211) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +721 -5
  3. data/README.md +1 -1
  4. data/bundler.gemspec +8 -11
  5. data/exe/bundle +7 -8
  6. data/exe/bundler +1 -1
  7. data/lib/bundler/.document +1 -0
  8. data/lib/bundler/build_metadata.rb +3 -3
  9. data/lib/bundler/cli/cache.rb +1 -1
  10. data/lib/bundler/cli/check.rb +4 -2
  11. data/lib/bundler/cli/common.rb +17 -3
  12. data/lib/bundler/cli/config.rb +10 -1
  13. data/lib/bundler/cli/doctor.rb +24 -5
  14. data/lib/bundler/cli/exec.rb +1 -6
  15. data/lib/bundler/cli/gem.rb +130 -26
  16. data/lib/bundler/cli/info.rb +27 -6
  17. data/lib/bundler/cli/init.rb +5 -1
  18. data/lib/bundler/cli/install.rb +23 -54
  19. data/lib/bundler/cli/issue.rb +4 -3
  20. data/lib/bundler/cli/list.rb +7 -1
  21. data/lib/bundler/cli/lock.rb +5 -1
  22. data/lib/bundler/cli/open.rb +1 -2
  23. data/lib/bundler/cli/outdated.rb +22 -14
  24. data/lib/bundler/cli/platform.rb +2 -2
  25. data/lib/bundler/cli/remove.rb +1 -2
  26. data/lib/bundler/cli/show.rb +1 -1
  27. data/lib/bundler/cli/update.rb +17 -8
  28. data/lib/bundler/cli.rb +51 -63
  29. data/lib/bundler/compact_index_client/cache.rb +0 -9
  30. data/lib/bundler/compact_index_client/updater.rb +26 -14
  31. data/lib/bundler/compact_index_client.rb +2 -8
  32. data/lib/bundler/current_ruby.rb +17 -6
  33. data/lib/bundler/definition.rb +260 -362
  34. data/lib/bundler/dependency.rb +23 -71
  35. data/lib/bundler/digest.rb +71 -0
  36. data/lib/bundler/dsl.rb +72 -76
  37. data/lib/bundler/endpoint_specification.rb +19 -13
  38. data/lib/bundler/env.rb +1 -1
  39. data/lib/bundler/environment_preserver.rb +4 -1
  40. data/lib/bundler/errors.rb +29 -3
  41. data/lib/bundler/feature_flag.rb +0 -5
  42. data/lib/bundler/fetcher/base.rb +6 -8
  43. data/lib/bundler/fetcher/compact_index.rb +10 -15
  44. data/lib/bundler/fetcher/downloader.rb +9 -6
  45. data/lib/bundler/fetcher/index.rb +0 -27
  46. data/lib/bundler/fetcher.rb +22 -23
  47. data/lib/bundler/friendly_errors.rb +26 -36
  48. data/lib/bundler/gem_helper.rb +21 -16
  49. data/lib/bundler/gem_helpers.rb +9 -2
  50. data/lib/bundler/gem_version_promoter.rb +14 -25
  51. data/lib/bundler/index.rb +11 -46
  52. data/lib/bundler/injector.rb +18 -4
  53. data/lib/bundler/inline.rb +4 -13
  54. data/lib/bundler/installer/gem_installer.rb +16 -21
  55. data/lib/bundler/installer/parallel_installer.rb +36 -15
  56. data/lib/bundler/installer/standalone.rb +42 -10
  57. data/lib/bundler/installer.rb +25 -41
  58. data/lib/bundler/lazy_specification.rb +52 -30
  59. data/lib/bundler/lockfile_generator.rb +2 -2
  60. data/lib/bundler/lockfile_parser.rb +18 -43
  61. data/lib/bundler/man/bundle-add.1 +21 -5
  62. data/lib/bundler/man/bundle-add.1.ronn +16 -4
  63. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  64. data/lib/bundler/man/bundle-cache.1 +7 -1
  65. data/lib/bundler/man/bundle-cache.1.ronn +7 -0
  66. data/lib/bundler/man/bundle-check.1 +1 -1
  67. data/lib/bundler/man/bundle-clean.1 +2 -2
  68. data/lib/bundler/man/bundle-clean.1.ronn +1 -1
  69. data/lib/bundler/man/bundle-config.1 +49 -22
  70. data/lib/bundler/man/bundle-config.1.ronn +49 -30
  71. data/lib/bundler/man/bundle-console.1 +53 -0
  72. data/lib/bundler/man/bundle-console.1.ronn +44 -0
  73. data/lib/bundler/man/bundle-doctor.1 +1 -1
  74. data/lib/bundler/man/bundle-exec.1 +2 -2
  75. data/lib/bundler/man/bundle-exec.1.ronn +1 -1
  76. data/lib/bundler/man/bundle-gem.1 +14 -1
  77. data/lib/bundler/man/bundle-gem.1.ronn +16 -0
  78. data/lib/bundler/man/bundle-help.1 +13 -0
  79. data/lib/bundler/man/bundle-help.1.ronn +12 -0
  80. data/lib/bundler/man/bundle-info.1 +1 -1
  81. data/lib/bundler/man/bundle-init.1 +1 -1
  82. data/lib/bundler/man/bundle-inject.1 +5 -2
  83. data/lib/bundler/man/bundle-inject.1.ronn +3 -1
  84. data/lib/bundler/man/bundle-install.1 +6 -2
  85. data/lib/bundler/man/bundle-install.1.ronn +8 -2
  86. data/lib/bundler/man/bundle-list.1 +1 -1
  87. data/lib/bundler/man/bundle-lock.1 +1 -1
  88. data/lib/bundler/man/bundle-open.1 +1 -1
  89. data/lib/bundler/man/bundle-outdated.1 +3 -10
  90. data/lib/bundler/man/bundle-outdated.1.ronn +1 -10
  91. data/lib/bundler/man/bundle-platform.1 +16 -6
  92. data/lib/bundler/man/bundle-platform.1.ronn +14 -7
  93. data/lib/bundler/man/bundle-plugin.1 +81 -0
  94. data/lib/bundler/man/bundle-plugin.1.ronn +59 -0
  95. data/lib/bundler/man/bundle-pristine.1 +1 -1
  96. data/lib/bundler/man/bundle-remove.1 +1 -1
  97. data/lib/bundler/man/bundle-show.1 +1 -1
  98. data/lib/bundler/man/bundle-update.1 +5 -5
  99. data/lib/bundler/man/bundle-update.1.ronn +5 -4
  100. data/lib/bundler/man/bundle-version.1 +35 -0
  101. data/lib/bundler/man/bundle-version.1.ronn +24 -0
  102. data/lib/bundler/man/bundle-viz.1 +4 -1
  103. data/lib/bundler/man/bundle-viz.1.ronn +2 -0
  104. data/lib/bundler/man/bundle.1 +15 -10
  105. data/lib/bundler/man/bundle.1.ronn +12 -7
  106. data/lib/bundler/man/gemfile.5 +117 -80
  107. data/lib/bundler/man/gemfile.5.ronn +105 -84
  108. data/lib/bundler/man/index.txt +4 -0
  109. data/lib/bundler/match_metadata.rb +13 -0
  110. data/lib/bundler/match_platform.rb +0 -1
  111. data/lib/bundler/match_remote_metadata.rb +29 -0
  112. data/lib/bundler/plugin/api/source.rb +24 -8
  113. data/lib/bundler/plugin/index.rb +4 -1
  114. data/lib/bundler/plugin/installer/git.rb +0 -4
  115. data/lib/bundler/plugin/installer/rubygems.rb +0 -4
  116. data/lib/bundler/plugin/installer.rb +10 -10
  117. data/lib/bundler/plugin/source_list.rb +4 -0
  118. data/lib/bundler/plugin.rb +30 -8
  119. data/lib/bundler/process_lock.rb +1 -1
  120. data/lib/bundler/remote_specification.rb +10 -4
  121. data/lib/bundler/resolver/base.rb +50 -0
  122. data/lib/bundler/resolver/spec_group.rb +31 -73
  123. data/lib/bundler/resolver.rb +193 -292
  124. data/lib/bundler/retry.rb +1 -1
  125. data/lib/bundler/ruby_dsl.rb +1 -1
  126. data/lib/bundler/ruby_version.rb +5 -18
  127. data/lib/bundler/rubygems_ext.rb +160 -26
  128. data/lib/bundler/rubygems_gem_installer.rb +86 -9
  129. data/lib/bundler/rubygems_integration.rb +46 -93
  130. data/lib/bundler/runtime.rb +18 -12
  131. data/lib/bundler/self_manager.rb +168 -0
  132. data/lib/bundler/settings.rb +98 -22
  133. data/lib/bundler/setup.rb +2 -2
  134. data/lib/bundler/shared_helpers.rb +15 -31
  135. data/lib/bundler/source/git/git_proxy.rb +8 -6
  136. data/lib/bundler/source/git.rb +29 -13
  137. data/lib/bundler/source/metadata.rb +3 -7
  138. data/lib/bundler/source/path/installer.rb +1 -1
  139. data/lib/bundler/source/path.rb +3 -1
  140. data/lib/bundler/source/rubygems.rb +199 -182
  141. data/lib/bundler/source/rubygems_aggregate.rb +68 -0
  142. data/lib/bundler/source.rb +24 -4
  143. data/lib/bundler/source_list.rb +104 -60
  144. data/lib/bundler/source_map.rb +71 -0
  145. data/lib/bundler/spec_set.rb +58 -52
  146. data/lib/bundler/stub_specification.rb +13 -3
  147. data/lib/bundler/templates/Executable +2 -4
  148. data/lib/bundler/templates/Executable.bundler +8 -8
  149. data/lib/bundler/templates/Executable.standalone +2 -4
  150. data/lib/bundler/templates/Gemfile +0 -2
  151. data/lib/bundler/templates/gems.rb +0 -3
  152. data/lib/bundler/templates/newgem/Gemfile.tt +5 -2
  153. data/lib/bundler/templates/newgem/README.md.tt +8 -12
  154. data/lib/bundler/templates/newgem/Rakefile.tt +15 -2
  155. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +16 -7
  156. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +5 -4
  157. data/lib/bundler/templates/newgem/newgem.gemspec.tt +19 -17
  158. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  159. data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  160. data/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
  161. data/lib/bundler/ui/shell.rb +1 -1
  162. data/lib/bundler/vendor/.document +1 -0
  163. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  164. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  165. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  166. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +57 -0
  167. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +39 -74
  168. data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  169. data/lib/bundler/vendor/molinillo/LICENSE +9 -0
  170. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +3 -3
  171. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +32 -26
  172. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  173. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +1 -1
  174. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  175. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  176. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +5 -5
  177. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +1 -2
  178. data/lib/bundler/vendor/thor/lib/thor/actions.rb +6 -2
  179. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
  180. data/lib/bundler/vendor/thor/lib/thor/error.rb +9 -4
  181. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +19 -1
  182. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +22 -4
  183. data/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  184. data/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  185. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  186. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +1 -1
  187. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  188. data/lib/bundler/vendor/tsort/lib/tsort.rb +452 -0
  189. data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  190. data/lib/bundler/vendor/uri/lib/uri/common.rb +17 -80
  191. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +0 -1
  192. data/lib/bundler/vendor/uri/lib/uri/generic.rb +5 -6
  193. data/lib/bundler/vendor/uri/lib/uri/http.rb +0 -1
  194. data/lib/bundler/vendor/uri/lib/uri/https.rb +0 -1
  195. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
  196. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +0 -1
  197. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +1 -14
  198. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +1 -12
  199. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  200. data/lib/bundler/vendor/uri/lib/uri/ws.rb +84 -0
  201. data/lib/bundler/vendor/uri/lib/uri/wss.rb +22 -0
  202. data/lib/bundler/vendor/uri/lib/uri.rb +0 -1
  203. data/lib/bundler/vendored_tsort.rb +4 -0
  204. data/lib/bundler/version.rb +1 -1
  205. data/lib/bundler/worker.rb +19 -4
  206. data/lib/bundler.rb +46 -39
  207. metadata +39 -12
  208. data/lib/bundler/dep_proxy.rb +0 -55
  209. data/lib/bundler/gemdeps.rb +0 -29
  210. data/lib/bundler/psyched_yaml.rb +0 -22
  211. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
@@ -7,72 +7,24 @@ require_relative "rubygems_ext"
7
7
  module Bundler
8
8
  class Dependency < Gem::Dependency
9
9
  attr_reader :autorequire
10
- attr_reader :groups, :platforms, :gemfile, :git, :branch
10
+ attr_reader :groups, :platforms, :gemfile, :path, :git, :github, :branch, :ref, :force_ruby_platform
11
11
 
12
+ ALL_RUBY_VERSIONS = ((18..27).to_a + (30..31).to_a).freeze
12
13
  PLATFORM_MAP = {
13
- :ruby => Gem::Platform::RUBY,
14
- :ruby_18 => Gem::Platform::RUBY,
15
- :ruby_19 => Gem::Platform::RUBY,
16
- :ruby_20 => Gem::Platform::RUBY,
17
- :ruby_21 => Gem::Platform::RUBY,
18
- :ruby_22 => Gem::Platform::RUBY,
19
- :ruby_23 => Gem::Platform::RUBY,
20
- :ruby_24 => Gem::Platform::RUBY,
21
- :ruby_25 => Gem::Platform::RUBY,
22
- :ruby_26 => Gem::Platform::RUBY,
23
- :mri => Gem::Platform::RUBY,
24
- :mri_18 => Gem::Platform::RUBY,
25
- :mri_19 => Gem::Platform::RUBY,
26
- :mri_20 => Gem::Platform::RUBY,
27
- :mri_21 => Gem::Platform::RUBY,
28
- :mri_22 => Gem::Platform::RUBY,
29
- :mri_23 => Gem::Platform::RUBY,
30
- :mri_24 => Gem::Platform::RUBY,
31
- :mri_25 => Gem::Platform::RUBY,
32
- :mri_26 => Gem::Platform::RUBY,
33
- :rbx => Gem::Platform::RUBY,
34
- :truffleruby => Gem::Platform::RUBY,
35
- :jruby => Gem::Platform::JAVA,
36
- :jruby_18 => Gem::Platform::JAVA,
37
- :jruby_19 => Gem::Platform::JAVA,
38
- :mswin => Gem::Platform::MSWIN,
39
- :mswin_18 => Gem::Platform::MSWIN,
40
- :mswin_19 => Gem::Platform::MSWIN,
41
- :mswin_20 => Gem::Platform::MSWIN,
42
- :mswin_21 => Gem::Platform::MSWIN,
43
- :mswin_22 => Gem::Platform::MSWIN,
44
- :mswin_23 => Gem::Platform::MSWIN,
45
- :mswin_24 => Gem::Platform::MSWIN,
46
- :mswin_25 => Gem::Platform::MSWIN,
47
- :mswin_26 => Gem::Platform::MSWIN,
48
- :mswin64 => Gem::Platform::MSWIN64,
49
- :mswin64_19 => Gem::Platform::MSWIN64,
50
- :mswin64_20 => Gem::Platform::MSWIN64,
51
- :mswin64_21 => Gem::Platform::MSWIN64,
52
- :mswin64_22 => Gem::Platform::MSWIN64,
53
- :mswin64_23 => Gem::Platform::MSWIN64,
54
- :mswin64_24 => Gem::Platform::MSWIN64,
55
- :mswin64_25 => Gem::Platform::MSWIN64,
56
- :mswin64_26 => Gem::Platform::MSWIN64,
57
- :mingw => Gem::Platform::MINGW,
58
- :mingw_18 => Gem::Platform::MINGW,
59
- :mingw_19 => Gem::Platform::MINGW,
60
- :mingw_20 => Gem::Platform::MINGW,
61
- :mingw_21 => Gem::Platform::MINGW,
62
- :mingw_22 => Gem::Platform::MINGW,
63
- :mingw_23 => Gem::Platform::MINGW,
64
- :mingw_24 => Gem::Platform::MINGW,
65
- :mingw_25 => Gem::Platform::MINGW,
66
- :mingw_26 => Gem::Platform::MINGW,
67
- :x64_mingw => Gem::Platform::X64_MINGW,
68
- :x64_mingw_20 => Gem::Platform::X64_MINGW,
69
- :x64_mingw_21 => Gem::Platform::X64_MINGW,
70
- :x64_mingw_22 => Gem::Platform::X64_MINGW,
71
- :x64_mingw_23 => Gem::Platform::X64_MINGW,
72
- :x64_mingw_24 => Gem::Platform::X64_MINGW,
73
- :x64_mingw_25 => Gem::Platform::X64_MINGW,
74
- :x64_mingw_26 => Gem::Platform::X64_MINGW,
75
- }.freeze
14
+ :ruby => [Gem::Platform::RUBY, ALL_RUBY_VERSIONS],
15
+ :mri => [Gem::Platform::RUBY, ALL_RUBY_VERSIONS],
16
+ :rbx => [Gem::Platform::RUBY],
17
+ :truffleruby => [Gem::Platform::RUBY],
18
+ :jruby => [Gem::Platform::JAVA, [18, 19]],
19
+ :windows => [Gem::Platform::WINDOWS, ALL_RUBY_VERSIONS],
20
+ :mswin => [Gem::Platform::MSWIN, ALL_RUBY_VERSIONS],
21
+ :mswin64 => [Gem::Platform::MSWIN64, ALL_RUBY_VERSIONS - [18]],
22
+ :mingw => [Gem::Platform::MINGW, ALL_RUBY_VERSIONS],
23
+ :x64_mingw => [Gem::Platform::X64_MINGW, ALL_RUBY_VERSIONS - [18, 19]],
24
+ }.each_with_object({}) do |(platform, spec), hash|
25
+ hash[platform] = spec[0]
26
+ spec[1]&.each {|version| hash[:"#{platform}_#{version}"] = spec[0] }
27
+ end.freeze
76
28
 
77
29
  def initialize(name, version, options = {}, &blk)
78
30
  type = options["type"] || :runtime
@@ -81,12 +33,16 @@ module Bundler
81
33
  @autorequire = nil
82
34
  @groups = Array(options["group"] || :default).map(&:to_sym)
83
35
  @source = options["source"]
36
+ @path = options["path"]
84
37
  @git = options["git"]
38
+ @github = options["github"]
85
39
  @branch = options["branch"]
40
+ @ref = options["ref"]
86
41
  @platforms = Array(options["platforms"])
87
42
  @env = options["env"]
88
43
  @should_include = options.fetch("should_include", true)
89
44
  @gemfile = options["gemfile"]
45
+ @force_ruby_platform = options["force_ruby_platform"]
90
46
 
91
47
  @autorequire = Array(options["require"] || []) if options.key?("require")
92
48
  end
@@ -96,15 +52,11 @@ module Bundler
96
52
  def gem_platforms(valid_platforms)
97
53
  return valid_platforms if @platforms.empty?
98
54
 
99
- valid_generic_platforms = valid_platforms.map {|p| [p, GemHelpers.generic(p)] }.to_h
100
- @gem_platforms ||= expanded_platforms.compact.uniq
101
-
102
- filtered_generic_platforms = valid_generic_platforms.values & @gem_platforms
103
- valid_generic_platforms.select {|_, v| filtered_generic_platforms.include?(v) }.keys
55
+ valid_platforms.select {|p| expanded_platforms.include?(GemHelpers.generic(p)) }
104
56
  end
105
57
 
106
58
  def expanded_platforms
107
- @platforms.map {|pl| PLATFORM_MAP[pl] }
59
+ @expanded_platforms ||= @platforms.map {|pl| PLATFORM_MAP[pl] }.compact.flatten.uniq
108
60
  end
109
61
 
110
62
  def should_include?
@@ -132,7 +84,7 @@ module Bundler
132
84
  def to_lock
133
85
  out = super
134
86
  out << "!" if source
135
- out << "\n"
87
+ out
136
88
  end
137
89
 
138
90
  def specific?
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This code was extracted from https://github.com/Solistra/ruby-digest which is under public domain
4
+ module Bundler
5
+ module Digest
6
+ # The initial constant values for the 32-bit constant words A, B, C, D, and
7
+ # E, respectively.
8
+ SHA1_WORDS = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0].freeze
9
+
10
+ # The 8-bit field used for bitwise `AND` masking. Defaults to `0xFFFFFFFF`.
11
+ SHA1_MASK = 0xFFFFFFFF
12
+
13
+ class << self
14
+ def sha1(string)
15
+ unless string.is_a?(String)
16
+ raise TypeError, "can't convert #{string.class.inspect} into String"
17
+ end
18
+
19
+ buffer = string.b
20
+
21
+ words = SHA1_WORDS.dup
22
+ generate_split_buffer(buffer) do |chunk|
23
+ w = []
24
+ chunk.each_slice(4) do |a, b, c, d|
25
+ w << (((a << 8 | b) << 8 | c) << 8 | d)
26
+ end
27
+ a, b, c, d, e = *words
28
+ (16..79).each do |i|
29
+ w[i] = SHA1_MASK & rotate((w[i-3] ^ w[i-8] ^ w[i-14] ^ w[i-16]), 1)
30
+ end
31
+ 0.upto(79) do |i|
32
+ case i
33
+ when 0..19
34
+ f = ((b & c) | (~b & d))
35
+ k = 0x5A827999
36
+ when 20..39
37
+ f = (b ^ c ^ d)
38
+ k = 0x6ED9EBA1
39
+ when 40..59
40
+ f = ((b & c) | (b & d) | (c & d))
41
+ k = 0x8F1BBCDC
42
+ when 60..79
43
+ f = (b ^ c ^ d)
44
+ k = 0xCA62C1D6
45
+ end
46
+ t = SHA1_MASK & (SHA1_MASK & rotate(a, 5) + f + e + k + w[i])
47
+ a, b, c, d, e = t, a, SHA1_MASK & rotate(b, 30), c, d # rubocop:disable Style/ParallelAssignment
48
+ end
49
+ mutated = [a, b, c, d, e]
50
+ words.map!.with_index {|word, index| SHA1_MASK & (word + mutated[index]) }
51
+ end
52
+
53
+ words.pack("N*").unpack("H*").first
54
+ end
55
+
56
+ private
57
+
58
+ def generate_split_buffer(string, &block)
59
+ size = string.bytesize * 8
60
+ buffer = string.bytes << 128
61
+ buffer << 0 while buffer.size % 64 != 56
62
+ buffer.concat([size].pack("Q>").bytes)
63
+ buffer.each_slice(64, &block)
64
+ end
65
+
66
+ def rotate(value, spaces)
67
+ value << spaces | value >> (32 - spaces)
68
+ end
69
+ end
70
+ end
71
+ end
data/lib/bundler/dsl.rb CHANGED
@@ -16,7 +16,9 @@ module Bundler
16
16
  VALID_PLATFORMS = Bundler::Dependency::PLATFORM_MAP.keys.freeze
17
17
 
18
18
  VALID_KEYS = %w[group groups git path glob name branch ref tag require submodules
19
- platform platforms type source install_if gemfile].freeze
19
+ platform platforms type source install_if gemfile force_ruby_platform].freeze
20
+
21
+ GITHUB_PULL_REQUEST_URL = %r{\Ahttps://github\.com/([A-Za-z0-9_\-\.]+/[A-Za-z0-9_\-\.]+)/pull/(\d+)\z}.freeze
20
22
 
21
23
  attr_reader :gemspecs
22
24
  attr_accessor :dependencies
@@ -44,7 +46,7 @@ module Bundler
44
46
  @gemfile = expanded_gemfile_path
45
47
  @gemfiles << expanded_gemfile_path
46
48
  contents ||= Bundler.read_file(@gemfile.to_s)
47
- instance_eval(contents.dup.tap{|x| x.untaint if RUBY_VERSION < "2.7" }, gemfile.to_s, 1)
49
+ instance_eval(contents.dup.tap {|x| x.untaint if RUBY_VERSION < "2.7" }, gemfile.to_s, 1)
48
50
  rescue Exception => e # rubocop:disable Lint/RescueException
49
51
  message = "There was an error " \
50
52
  "#{e.is_a?(GemfileEvalError) ? "evaluating" : "parsing"} " \
@@ -65,7 +67,6 @@ module Bundler
65
67
 
66
68
  gemspecs = Gem::Util.glob_files_in_dir("{,*}.gemspec", expanded_path).map {|g| Bundler.load_gemspec(g) }.compact
67
69
  gemspecs.reject! {|s| s.name != name } if name
68
- Index.sort_specs(gemspecs)
69
70
  specs_by_name_and_version = gemspecs.group_by {|s| [s.name, s.version] }
70
71
 
71
72
  case specs_by_name_and_version.size
@@ -103,8 +104,8 @@ module Bundler
103
104
  if current = @dependencies.find {|d| d.name == dep.name }
104
105
  deleted_dep = @dependencies.delete(current) if current.type == :development
105
106
 
106
- if current.requirement != dep.requirement
107
- unless deleted_dep
107
+ unless deleted_dep
108
+ if current.requirement != dep.requirement
108
109
  return if dep.type == :development
109
110
 
110
111
  update_prompt = ""
@@ -122,21 +123,16 @@ module Bundler
122
123
  raise GemfileError, "You cannot specify the same gem twice with different version requirements.\n" \
123
124
  "You specified: #{current.name} (#{current.requirement}) and #{dep.name} (#{dep.requirement})" \
124
125
  "#{update_prompt}"
125
- end
126
-
127
- else
128
- Bundler.ui.warn "Your Gemfile lists the gem #{current.name} (#{current.requirement}) more than once.\n" \
129
- "You should probably keep only one of them.\n" \
130
- "Remove any duplicate entries and specify the gem only once.\n" \
131
- "While it's not a problem now, it could cause errors if you change the version of one of them later."
132
- end
133
-
134
- if current.source != dep.source
135
- unless deleted_dep
126
+ elsif current.source != dep.source
136
127
  return if dep.type == :development
137
128
  raise GemfileError, "You cannot specify the same gem twice coming from different sources.\n" \
138
129
  "You specified that #{dep.name} (#{dep.requirement}) should come from " \
139
130
  "#{current.source || "an unspecified source"} and #{dep.source}\n"
131
+ else
132
+ Bundler.ui.warn "Your Gemfile lists the gem #{current.name} (#{current.requirement}) more than once.\n" \
133
+ "You should probably keep only one of them.\n" \
134
+ "Remove any duplicate entries and specify the gem only once.\n" \
135
+ "While it's not a problem now, it could cause errors if you change the version of one of them later."
140
136
  end
141
137
  end
142
138
  end
@@ -164,8 +160,7 @@ module Bundler
164
160
  elsif block_given?
165
161
  with_source(@sources.add_rubygems_source("remotes" => source), &blk)
166
162
  else
167
- check_primary_source_safety(@sources)
168
- @sources.global_rubygems_source = source
163
+ @sources.add_global_rubygems_remote(source)
169
164
  end
170
165
  end
171
166
 
@@ -183,24 +178,14 @@ module Bundler
183
178
  end
184
179
 
185
180
  def path(path, options = {}, &blk)
186
- unless block_given?
187
- msg = "You can no longer specify a path source by itself. Instead, \n" \
188
- "either use the :path option on a gem, or specify the gems that \n" \
189
- "bundler should find in the path source by passing a block to \n" \
190
- "the path method, like: \n\n" \
191
- " path 'dir/containing/rails' do\n" \
192
- " gem 'rails'\n" \
193
- " end\n\n"
194
-
195
- raise DeprecatedError, msg if Bundler.feature_flag.disable_multisource?
196
- SharedHelpers.major_deprecation(2, msg.strip)
197
- end
198
-
199
181
  source_options = normalize_hash(options).merge(
200
182
  "path" => Pathname.new(path),
201
183
  "root_path" => gemfile_root,
202
184
  "gemspec" => gemspecs.find {|g| g.name == options["name"] }
203
185
  )
186
+
187
+ source_options["global"] = true unless block_given?
188
+
204
189
  source = @sources.add_path_source(source_options)
205
190
  with_source(source, &blk)
206
191
  end
@@ -229,6 +214,7 @@ module Bundler
229
214
  end
230
215
 
231
216
  def to_definition(lockfile, unlock)
217
+ check_primary_source_safety
232
218
  Definition.new(lockfile, @dependencies, @sources, unlock, @ruby_version, @optional_groups, @gemfiles)
233
219
  end
234
220
 
@@ -279,30 +265,33 @@ module Bundler
279
265
  raise GemfileError, "Undefined local variable or method `#{name}' for Gemfile"
280
266
  end
281
267
 
268
+ def check_primary_source_safety
269
+ check_path_source_safety
270
+ check_rubygems_source_safety
271
+ end
272
+
282
273
  private
283
274
 
284
275
  def add_git_sources
285
276
  git_source(:github) do |repo_name|
286
- warn_deprecated_git_source(:github, <<-'RUBY'.strip, 'Change any "reponame" :github sources to "username/reponame".')
287
- "https://github.com/#{repo_name}.git"
288
- RUBY
289
- repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
290
- "https://github.com/#{repo_name}.git"
277
+ if repo_name =~ GITHUB_PULL_REQUEST_URL
278
+ {
279
+ "git" => "https://github.com/#{$1}.git",
280
+ "branch" => "refs/pull/#{$2}/head",
281
+ "ref" => nil,
282
+ "tag" => nil,
283
+ }
284
+ else
285
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
286
+ "https://github.com/#{repo_name}.git"
287
+ end
291
288
  end
292
289
 
293
290
  git_source(:gist) do |repo_name|
294
- warn_deprecated_git_source(:gist, '"https://gist.github.com/#{repo_name}.git"')
295
-
296
291
  "https://gist.github.com/#{repo_name}.git"
297
292
  end
298
293
 
299
294
  git_source(:bitbucket) do |repo_name|
300
- warn_deprecated_git_source(:bitbucket, <<-'RUBY'.strip)
301
- user_name, repo_name = repo_name.split("/")
302
- repo_name ||= user_name
303
- "https://#{user_name}@bitbucket.org/#{user_name}/#{repo_name}.git"
304
- RUBY
305
-
306
295
  user_name, repo_name = repo_name.split("/")
307
296
  repo_name ||= user_name
308
297
  "https://#{user_name}@bitbucket.org/#{user_name}/#{repo_name}.git"
@@ -373,7 +362,11 @@ repo_name ||= user_name
373
362
 
374
363
  git_name = (git_names & opts.keys).last
375
364
  if @git_sources[git_name]
376
- opts["git"] = @git_sources[git_name].call(opts[git_name])
365
+ git_opts = @git_sources[git_name].call(opts[git_name])
366
+ git_opts = { "git" => git_opts } if git_opts.is_a?(String)
367
+ opts.merge!(git_opts) do |key, _gemfile_value, _git_source_value|
368
+ raise GemfileError, %(The :#{key} option can't be used with `#{git_name}: #{opts[git_name].inspect}`)
369
+ end
377
370
  end
378
371
 
379
372
  %w[git path].each do |type|
@@ -440,42 +433,47 @@ repo_name ||= user_name
440
433
  end
441
434
  end
442
435
 
443
- def check_primary_source_safety(source_list)
444
- return if source_list.rubygems_primary_remotes.empty? && source_list.global_rubygems_source.nil?
436
+ def check_path_source_safety
437
+ return if @sources.global_path_source.nil?
438
+
439
+ msg = "You can no longer specify a path source by itself. Instead, \n" \
440
+ "either use the :path option on a gem, or specify the gems that \n" \
441
+ "bundler should find in the path source by passing a block to \n" \
442
+ "the path method, like: \n\n" \
443
+ " path 'dir/containing/rails' do\n" \
444
+ " gem 'rails'\n" \
445
+ " end\n\n"
446
+
447
+ SharedHelpers.major_deprecation(2, msg.strip)
448
+ end
449
+
450
+ def check_rubygems_source_safety
451
+ if @sources.implicit_global_source?
452
+ implicit_global_source_warning
453
+ elsif @sources.aggregate_global_source?
454
+ multiple_global_source_warning
455
+ end
456
+ end
457
+
458
+ def implicit_global_source_warning
459
+ Bundler::SharedHelpers.major_deprecation 2, "This Gemfile does not include an explicit global source. " \
460
+ "Not using an explicit global source may result in a different lockfile being generated depending on " \
461
+ "the gems you have installed locally before bundler is run. " \
462
+ "Instead, define a global source in your Gemfile like this: source \"https://rubygems.org\"."
463
+ end
445
464
 
446
- if Bundler.feature_flag.disable_multisource?
447
- msg = "This Gemfile contains multiple primary sources. " \
465
+ def multiple_global_source_warning
466
+ if Bundler.feature_flag.bundler_3_mode?
467
+ msg = "This Gemfile contains multiple global sources. " \
448
468
  "Each source after the first must include a block to indicate which gems " \
449
469
  "should come from that source"
450
- unless Bundler.feature_flag.bundler_2_mode?
451
- msg += ". To downgrade this error to a warning, run " \
452
- "`bundle config unset disable_multisource`"
453
- end
454
470
  raise GemfileEvalError, msg
455
471
  else
456
- Bundler::SharedHelpers.major_deprecation 2, "Your Gemfile contains multiple primary sources. " \
472
+ Bundler::SharedHelpers.major_deprecation 2, "Your Gemfile contains multiple global sources. " \
457
473
  "Using `source` more than once without a block is a security risk, and " \
458
474
  "may result in installing unexpected gems. To resolve this warning, use " \
459
- "a block to indicate which gems should come from the secondary source. " \
460
- "To upgrade this warning to an error, run `bundle config set --local " \
461
- "disable_multisource true`."
462
- end
463
- end
464
-
465
- def warn_deprecated_git_source(name, replacement, additional_message = nil)
466
- additional_message &&= " #{additional_message}"
467
- replacement = if replacement.count("\n").zero?
468
- "{|repo_name| #{replacement} }"
469
- else
470
- "do |repo_name|\n#{replacement.to_s.gsub(/^/, " ")}\n end"
475
+ "a block to indicate which gems should come from the secondary source."
471
476
  end
472
-
473
- Bundler::SharedHelpers.major_deprecation 3, <<-EOS
474
- The :#{name} git source is deprecated, and will be removed in the future.#{additional_message} Add this code to the top of your Gemfile to ensure it continues to work:
475
-
476
- git_source(:#{name}) #{replacement}
477
-
478
- EOS
479
477
  end
480
478
 
481
479
  class DSLError < GemfileError
@@ -512,9 +510,7 @@ The :#{name} git source is deprecated, and will be removed in the future.#{addit
512
510
  # be raised.
513
511
  #
514
512
  def contents
515
- @contents ||= begin
516
- dsl_path && File.exist?(dsl_path) && File.read(dsl_path)
517
- end
513
+ @contents ||= dsl_path && File.exist?(dsl_path) && File.read(dsl_path)
518
514
  end
519
515
 
520
516
  # The message of the exception reports the content of podspec for the
@@ -3,17 +3,17 @@
3
3
  module Bundler
4
4
  # used for Creating Specifications from the Gemcutter Endpoint
5
5
  class EndpointSpecification < Gem::Specification
6
- ILLFORMED_MESSAGE = 'Ill-formed requirement ["#<YAML::Syck::DefaultKey'.freeze
7
- include MatchPlatform
6
+ include MatchRemoteMetadata
8
7
 
9
- attr_reader :name, :version, :platform, :required_rubygems_version, :required_ruby_version, :checksum
8
+ attr_reader :name, :version, :platform, :checksum
10
9
  attr_accessor :source, :remote, :dependencies
11
10
 
12
- def initialize(name, version, platform, dependencies, metadata = nil)
11
+ def initialize(name, version, platform, spec_fetcher, dependencies, metadata = nil)
13
12
  super()
14
13
  @name = name
15
14
  @version = Gem::Version.create version
16
- @platform = platform
15
+ @platform = Gem::Platform.new(platform)
16
+ @spec_fetcher = spec_fetcher
17
17
  @dependencies = dependencies.map {|dep, reqs| build_dependency(dep, reqs) }
18
18
 
19
19
  @loaded_from = nil
@@ -26,6 +26,10 @@ module Bundler
26
26
  @platform
27
27
  end
28
28
 
29
+ def identifier
30
+ @__identifier ||= [name, version, platform.to_s]
31
+ end
32
+
29
33
  # needed for standalone, load required_paths from local gemspec
30
34
  # after the gem is installed
31
35
  def require_paths
@@ -106,12 +110,21 @@ module Bundler
106
110
 
107
111
  private
108
112
 
113
+ def _remote_specification
114
+ @_remote_specification ||= @spec_fetcher.fetch_spec([@name, @version, @platform])
115
+ end
116
+
109
117
  def local_specification_path
110
118
  "#{base_dir}/specifications/#{full_name}.gemspec"
111
119
  end
112
120
 
113
121
  def parse_metadata(data)
114
- return unless data
122
+ unless data
123
+ @required_ruby_version = nil
124
+ @required_rubygems_version = nil
125
+ return
126
+ end
127
+
115
128
  data.each do |k, v|
116
129
  next unless v
117
130
  case k.to_s
@@ -129,13 +142,6 @@ module Bundler
129
142
 
130
143
  def build_dependency(name, requirements)
131
144
  Gem::Dependency.new(name, requirements)
132
- rescue ArgumentError => e
133
- raise unless e.message.include?(ILLFORMED_MESSAGE)
134
- puts # we shouldn't print the error message on the "fetching info" status line
135
- raise GemspecError,
136
- "Unfortunately, the gem #{name} (#{version}) has an invalid " \
137
- "gemspec.\nPlease ask the gem author to yank the bad version to fix " \
138
- "this issue. For more information, see http://bit.ly/syck-defaultkey."
139
145
  end
140
146
  end
141
147
  end
data/lib/bundler/env.rb CHANGED
@@ -71,7 +71,7 @@ module Bundler
71
71
  def self.ruby_version
72
72
  str = String.new(RUBY_VERSION)
73
73
  str << "p#{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL
74
- str << " (#{RUBY_RELEASE_DATE} revision #{RUBY_REVISION}) [#{RUBY_PLATFORM}]"
74
+ str << " (#{RUBY_RELEASE_DATE} revision #{RUBY_REVISION}) [#{Gem::Platform.local}]"
75
75
  end
76
76
 
77
77
  def self.git_version
@@ -38,7 +38,10 @@ module Bundler
38
38
 
39
39
  # Replaces `ENV` with the bundler environment variables backed up
40
40
  def replace_with_backup
41
- ENV.replace(backup) unless Gem.win_platform?
41
+ unless Gem.win_platform?
42
+ ENV.replace(backup)
43
+ return
44
+ end
42
45
 
43
46
  # Fallback logic for Windows below to workaround
44
47
  # https://bugs.ruby-lang.org/issues/16798. Can be dropped once all
@@ -41,12 +41,14 @@ module Bundler
41
41
  class GemspecError < BundlerError; status_code(14); end
42
42
  class InvalidOption < BundlerError; status_code(15); end
43
43
  class ProductionError < BundlerError; status_code(16); end
44
+
44
45
  class HTTPError < BundlerError
45
46
  status_code(17)
46
47
  def filter_uri(uri)
47
48
  URICredentialsFilter.credential_filtered_uri(uri)
48
49
  end
49
50
  end
51
+
50
52
  class RubyVersionMismatch < BundlerError; status_code(18); end
51
53
  class SecurityError < BundlerError; status_code(19); end
52
54
  class LockfileError < BundlerError; status_code(20); end
@@ -75,10 +77,22 @@ module Bundler
75
77
  end
76
78
  end
77
79
 
80
+ def permission_type
81
+ case @permission_type
82
+ when :create
83
+ "executable permissions for all parent directories and write permissions for `#{parent_folder}`"
84
+ else
85
+ "#{@permission_type} permissions for that path"
86
+ end
87
+ end
88
+
89
+ def parent_folder
90
+ File.dirname(@path)
91
+ end
92
+
78
93
  def message
79
94
  "There was an error while trying to #{action} `#{@path}`. " \
80
- "It is likely that you need to grant #{@permission_type} permissions " \
81
- "for that path."
95
+ "It is likely that you need to grant #{permission_type}."
82
96
  end
83
97
 
84
98
  status_code(23)
@@ -122,7 +136,7 @@ module Bundler
122
136
 
123
137
  class VirtualProtocolError < BundlerError
124
138
  def message
125
- "There was an error relating to virtualization and file access." \
139
+ "There was an error relating to virtualization and file access. " \
126
140
  "It is likely that you need to grant access to or mount some file system correctly."
127
141
  end
128
142
 
@@ -156,4 +170,16 @@ module Bundler
156
170
 
157
171
  status_code(32)
158
172
  end
173
+
174
+ class DirectoryRemovalError < BundlerError
175
+ def initialize(orig_exception, msg)
176
+ full_message = "#{msg}.\n" \
177
+ "The underlying error was #{orig_exception.class}: #{orig_exception.message}, with backtrace:\n" \
178
+ " #{orig_exception.backtrace.join("\n ")}\n\n" \
179
+ "Bundler Error Backtrace:"
180
+ super(full_message)
181
+ end
182
+
183
+ status_code(36)
184
+ end
159
185
  end
@@ -31,19 +31,14 @@ module Bundler
31
31
  settings_flag(:auto_clean_without_path) { bundler_3_mode? }
32
32
  settings_flag(:cache_all) { bundler_3_mode? }
33
33
  settings_flag(:default_install_uses_path) { bundler_3_mode? }
34
- settings_flag(:deployment_means_frozen) { bundler_3_mode? }
35
- settings_flag(:disable_multisource) { bundler_3_mode? }
36
34
  settings_flag(:forget_cli_options) { bundler_3_mode? }
37
35
  settings_flag(:global_gem_cache) { bundler_3_mode? }
38
- settings_flag(:only_update_to_newer_versions) { bundler_3_mode? }
39
36
  settings_flag(:path_relative_to_cwd) { bundler_3_mode? }
40
37
  settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }
41
38
  settings_flag(:print_only_version_number) { bundler_3_mode? }
42
39
  settings_flag(:setup_makes_kernel_gem_public) { !bundler_3_mode? }
43
40
  settings_flag(:suppress_install_using_messages) { bundler_3_mode? }
44
- settings_flag(:unlock_source_unlocks_spec) { !bundler_3_mode? }
45
41
  settings_flag(:update_requires_all_flag) { bundler_4_mode? }
46
- settings_flag(:use_gem_version_promoter_for_major_updates) { bundler_3_mode? }
47
42
 
48
43
  settings_option(:default_cli_command) { bundler_3_mode? ? :cli_help : :install }
49
44
 
@@ -19,14 +19,12 @@ module Bundler
19
19
  end
20
20
 
21
21
  def fetch_uri
22
- @fetch_uri ||= begin
23
- if remote_uri.host == "rubygems.org"
24
- uri = remote_uri.dup
25
- uri.host = "index.rubygems.org"
26
- uri
27
- else
28
- remote_uri
29
- end
22
+ @fetch_uri ||= if remote_uri.host == "rubygems.org"
23
+ uri = remote_uri.dup
24
+ uri.host = "index.rubygems.org"
25
+ uri
26
+ else
27
+ remote_uri
30
28
  end
31
29
  end
32
30