bundler 2.2.33 → 2.4.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (263) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +682 -1
  3. data/README.md +3 -6
  4. data/bundler.gemspec +8 -10
  5. data/exe/bundle +12 -24
  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/add.rb +1 -1
  10. data/lib/bundler/cli/binstubs.rb +5 -1
  11. data/lib/bundler/cli/check.rb +1 -1
  12. data/lib/bundler/cli/common.rb +4 -2
  13. data/lib/bundler/cli/config.rb +10 -1
  14. data/lib/bundler/cli/console.rb +2 -2
  15. data/lib/bundler/cli/doctor.rb +7 -1
  16. data/lib/bundler/cli/gem.rb +73 -41
  17. data/lib/bundler/cli/info.rb +11 -2
  18. data/lib/bundler/cli/init.rb +6 -2
  19. data/lib/bundler/cli/install.rb +15 -33
  20. data/lib/bundler/cli/lock.rb +8 -5
  21. data/lib/bundler/cli/open.rb +6 -4
  22. data/lib/bundler/cli/outdated.rb +13 -6
  23. data/lib/bundler/cli/platform.rb +2 -2
  24. data/lib/bundler/cli/show.rb +1 -1
  25. data/lib/bundler/cli/update.rb +6 -2
  26. data/lib/bundler/cli/viz.rb +1 -1
  27. data/lib/bundler/cli.rb +63 -20
  28. data/lib/bundler/compact_index_client/cache.rb +1 -10
  29. data/lib/bundler/compact_index_client/updater.rb +53 -39
  30. data/lib/bundler/compact_index_client.rb +0 -6
  31. data/lib/bundler/constants.rb +1 -1
  32. data/lib/bundler/current_ruby.rb +18 -6
  33. data/lib/bundler/definition.rb +289 -165
  34. data/lib/bundler/dependency.rb +24 -71
  35. data/lib/bundler/digest.rb +1 -1
  36. data/lib/bundler/dsl.rb +13 -45
  37. data/lib/bundler/endpoint_specification.rb +15 -13
  38. data/lib/bundler/env.rb +2 -2
  39. data/lib/bundler/environment_preserver.rb +3 -2
  40. data/lib/bundler/errors.rb +15 -15
  41. data/lib/bundler/feature_flag.rb +0 -2
  42. data/lib/bundler/fetcher/base.rb +6 -8
  43. data/lib/bundler/fetcher/compact_index.rb +18 -25
  44. data/lib/bundler/fetcher/dependency.rb +2 -6
  45. data/lib/bundler/fetcher/downloader.rb +2 -5
  46. data/lib/bundler/fetcher/index.rb +0 -26
  47. data/lib/bundler/fetcher.rb +22 -29
  48. data/lib/bundler/force_platform.rb +18 -0
  49. data/lib/bundler/friendly_errors.rb +21 -7
  50. data/lib/bundler/gem_helper.rb +2 -2
  51. data/lib/bundler/gem_helpers.rb +9 -2
  52. data/lib/bundler/gem_version_promoter.rb +53 -98
  53. data/lib/bundler/graph.rb +3 -3
  54. data/lib/bundler/index.rb +13 -51
  55. data/lib/bundler/injector.rb +18 -4
  56. data/lib/bundler/inline.rb +9 -21
  57. data/lib/bundler/installer/gem_installer.rb +13 -5
  58. data/lib/bundler/installer/parallel_installer.rb +3 -33
  59. data/lib/bundler/installer/standalone.rb +42 -11
  60. data/lib/bundler/installer.rb +21 -45
  61. data/lib/bundler/lazy_specification.rb +55 -54
  62. data/lib/bundler/lockfile_generator.rb +3 -3
  63. data/lib/bundler/lockfile_parser.rb +29 -27
  64. data/lib/bundler/man/bundle-add.1 +21 -5
  65. data/lib/bundler/man/bundle-add.1.ronn +16 -4
  66. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  67. data/lib/bundler/man/bundle-cache.1 +9 -3
  68. data/lib/bundler/man/bundle-cache.1.ronn +9 -2
  69. data/lib/bundler/man/bundle-check.1 +1 -1
  70. data/lib/bundler/man/bundle-clean.1 +2 -2
  71. data/lib/bundler/man/bundle-clean.1.ronn +1 -1
  72. data/lib/bundler/man/bundle-config.1 +32 -16
  73. data/lib/bundler/man/bundle-config.1.ronn +29 -20
  74. data/lib/bundler/man/bundle-console.1 +53 -0
  75. data/lib/bundler/man/bundle-console.1.ronn +44 -0
  76. data/lib/bundler/man/bundle-doctor.1 +1 -1
  77. data/lib/bundler/man/bundle-exec.1 +6 -6
  78. data/lib/bundler/man/bundle-exec.1.ronn +6 -6
  79. data/lib/bundler/man/bundle-gem.1 +27 -37
  80. data/lib/bundler/man/bundle-gem.1.ronn +5 -5
  81. data/lib/bundler/man/bundle-help.1 +13 -0
  82. data/lib/bundler/man/bundle-help.1.ronn +12 -0
  83. data/lib/bundler/man/bundle-info.1 +1 -1
  84. data/lib/bundler/man/bundle-init.1 +5 -1
  85. data/lib/bundler/man/bundle-init.1.ronn +2 -0
  86. data/lib/bundler/man/bundle-inject.1 +5 -2
  87. data/lib/bundler/man/bundle-inject.1.ronn +3 -1
  88. data/lib/bundler/man/bundle-install.1 +6 -31
  89. data/lib/bundler/man/bundle-install.1.ronn +8 -31
  90. data/lib/bundler/man/bundle-list.1 +1 -1
  91. data/lib/bundler/man/bundle-lock.1 +1 -1
  92. data/lib/bundler/man/bundle-open.1 +22 -2
  93. data/lib/bundler/man/bundle-open.1.ronn +9 -1
  94. data/lib/bundler/man/bundle-outdated.1 +15 -18
  95. data/lib/bundler/man/bundle-outdated.1.ronn +13 -19
  96. data/lib/bundler/man/bundle-platform.1 +16 -6
  97. data/lib/bundler/man/bundle-platform.1.ronn +14 -7
  98. data/lib/bundler/man/bundle-plugin.1 +81 -0
  99. data/lib/bundler/man/bundle-plugin.1.ronn +59 -0
  100. data/lib/bundler/man/bundle-pristine.1 +1 -1
  101. data/lib/bundler/man/bundle-remove.1 +1 -1
  102. data/lib/bundler/man/bundle-show.1 +1 -1
  103. data/lib/bundler/man/bundle-update.1 +2 -2
  104. data/lib/bundler/man/bundle-update.1.ronn +2 -1
  105. data/lib/bundler/man/bundle-version.1 +35 -0
  106. data/lib/bundler/man/bundle-version.1.ronn +24 -0
  107. data/lib/bundler/man/bundle-viz.1 +4 -1
  108. data/lib/bundler/man/bundle-viz.1.ronn +2 -0
  109. data/lib/bundler/man/bundle.1 +15 -10
  110. data/lib/bundler/man/bundle.1.ronn +12 -7
  111. data/lib/bundler/man/gemfile.5 +94 -83
  112. data/lib/bundler/man/gemfile.5.ronn +100 -87
  113. data/lib/bundler/man/index.txt +4 -0
  114. data/lib/bundler/match_metadata.rb +13 -0
  115. data/lib/bundler/match_platform.rb +0 -1
  116. data/lib/bundler/match_remote_metadata.rb +29 -0
  117. data/lib/bundler/mirror.rb +5 -7
  118. data/lib/bundler/plugin/api/source.rb +3 -9
  119. data/lib/bundler/plugin/index.rb +4 -4
  120. data/lib/bundler/plugin/installer/git.rb +0 -4
  121. data/lib/bundler/plugin/installer/rubygems.rb +0 -8
  122. data/lib/bundler/plugin/installer.rb +6 -3
  123. data/lib/bundler/plugin.rb +3 -1
  124. data/lib/bundler/process_lock.rb +1 -1
  125. data/lib/bundler/remote_specification.rb +7 -5
  126. data/lib/bundler/resolver/base.rb +107 -0
  127. data/lib/bundler/resolver/candidate.rb +94 -0
  128. data/lib/bundler/resolver/incompatibility.rb +15 -0
  129. data/lib/bundler/resolver/package.rb +72 -0
  130. data/lib/bundler/resolver/root.rb +25 -0
  131. data/lib/bundler/resolver/spec_group.rb +43 -71
  132. data/lib/bundler/resolver.rb +342 -302
  133. data/lib/bundler/ruby_dsl.rb +1 -1
  134. data/lib/bundler/ruby_version.rb +6 -19
  135. data/lib/bundler/rubygems_ext.rb +149 -28
  136. data/lib/bundler/rubygems_gem_installer.rb +32 -20
  137. data/lib/bundler/rubygems_integration.rb +24 -95
  138. data/lib/bundler/runtime.rb +2 -7
  139. data/lib/bundler/safe_marshal.rb +31 -0
  140. data/lib/bundler/self_manager.rb +168 -0
  141. data/lib/bundler/settings.rb +7 -12
  142. data/lib/bundler/setup.rb +4 -1
  143. data/lib/bundler/shared_helpers.rb +15 -22
  144. data/lib/bundler/source/git/git_proxy.rb +237 -74
  145. data/lib/bundler/source/git.rb +54 -38
  146. data/lib/bundler/source/metadata.rb +3 -4
  147. data/lib/bundler/source/path/installer.rb +1 -22
  148. data/lib/bundler/source/path.rb +7 -7
  149. data/lib/bundler/source/rubygems.rb +85 -128
  150. data/lib/bundler/source.rb +4 -5
  151. data/lib/bundler/source_list.rb +12 -2
  152. data/lib/bundler/source_map.rb +15 -2
  153. data/lib/bundler/spec_set.rb +62 -34
  154. data/lib/bundler/stub_specification.rb +5 -3
  155. data/lib/bundler/templates/Executable +3 -5
  156. data/lib/bundler/templates/Executable.bundler +6 -11
  157. data/lib/bundler/templates/Executable.standalone +4 -4
  158. data/lib/bundler/templates/Gemfile +0 -2
  159. data/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
  160. data/lib/bundler/templates/newgem/Gemfile.tt +3 -0
  161. data/lib/bundler/templates/newgem/README.md.tt +7 -11
  162. data/lib/bundler/templates/newgem/Rakefile.tt +22 -2
  163. data/lib/bundler/templates/newgem/bin/console.tt +0 -4
  164. data/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
  165. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
  166. data/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +10 -0
  167. data/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
  168. data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +1 -1
  169. data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
  170. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +11 -1
  171. data/lib/bundler/templates/newgem/gitignore.tt +3 -0
  172. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +13 -4
  173. data/lib/bundler/templates/newgem/newgem.gemspec.tt +11 -4
  174. data/lib/bundler/templates/newgem/standard.yml.tt +1 -0
  175. data/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
  176. data/lib/bundler/ui/shell.rb +36 -13
  177. data/lib/bundler/ui/silent.rb +21 -5
  178. data/lib/bundler/uri_normalizer.rb +23 -0
  179. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +3 -3
  180. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +0 -1
  181. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +3 -1
  182. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1351 -409
  183. data/lib/bundler/vendor/net-http-persistent/README.rdoc +1 -1
  184. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1 -1
  185. data/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
  186. data/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
  187. data/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
  188. data/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
  189. data/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +150 -0
  190. data/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
  191. data/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
  192. data/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
  193. data/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
  194. data/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +60 -0
  195. data/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
  196. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
  197. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +129 -0
  198. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +411 -0
  199. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +248 -0
  200. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
  201. data/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
  202. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +6 -6
  203. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +1 -2
  204. data/lib/bundler/vendor/thor/lib/thor/actions.rb +6 -2
  205. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
  206. data/lib/bundler/vendor/thor/lib/thor/error.rb +9 -4
  207. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +19 -1
  208. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +23 -5
  209. data/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  210. data/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  211. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  212. data/lib/bundler/vendor/tsort/lib/tsort.rb +318 -319
  213. data/lib/bundler/vendor/uri/lib/uri/common.rb +76 -91
  214. data/lib/bundler/vendor/uri/lib/uri/file.rb +7 -1
  215. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +2 -2
  216. data/lib/bundler/vendor/uri/lib/uri/generic.rb +32 -13
  217. data/lib/bundler/vendor/uri/lib/uri/http.rb +40 -3
  218. data/lib/bundler/vendor/uri/lib/uri/https.rb +2 -2
  219. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +2 -2
  220. data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +2 -1
  221. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +2 -3
  222. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +16 -23
  223. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +12 -18
  224. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  225. data/lib/bundler/vendor/uri/lib/uri/ws.rb +83 -0
  226. data/lib/bundler/vendor/uri/lib/uri/wss.rb +23 -0
  227. data/lib/bundler/vendor/uri/lib/uri.rb +3 -3
  228. data/lib/bundler/vendored_persistent.rb +1 -33
  229. data/lib/bundler/{vendored_tmpdir.rb → vendored_pub_grub.rb} +1 -1
  230. data/lib/bundler/version.rb +5 -1
  231. data/lib/bundler/worker.rb +5 -7
  232. data/lib/bundler.rb +47 -82
  233. metadata +52 -38
  234. data/lib/bundler/dep_proxy.rb +0 -55
  235. data/lib/bundler/gemdeps.rb +0 -29
  236. data/lib/bundler/psyched_yaml.rb +0 -22
  237. data/lib/bundler/templates/gems.rb +0 -8
  238. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +0 -5
  239. data/lib/bundler/templates/newgem/travis.yml.tt +0 -6
  240. data/lib/bundler/vendor/molinillo/LICENSE +0 -9
  241. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
  242. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -88
  243. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -36
  244. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -66
  245. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -62
  246. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -63
  247. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -61
  248. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -126
  249. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -46
  250. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -36
  251. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -164
  252. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -255
  253. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -143
  254. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -6
  255. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -112
  256. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -67
  257. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -839
  258. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -46
  259. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -58
  260. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -11
  261. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +0 -154
  262. data/lib/bundler/vendored_molinillo.rb +0 -4
  263. data/lib/bundler/version_ranges.rb +0 -122
@@ -28,10 +28,10 @@ module Bundler
28
28
  def initialize(command, path, extra_info = nil)
29
29
  @command = command
30
30
 
31
- msg = String.new
32
- msg << "Git error: command `#{command}` in directory #{path} has failed."
31
+ msg = String.new("Git error: command `#{command}`")
32
+ msg << " in directory #{path}" if path
33
+ msg << " has failed."
33
34
  msg << "\n#{extra_info}" if extra_info
34
- msg << "\nIf this error persists you could try removing the cache directory '#{path}'" if path.exist?
35
35
  super msg
36
36
  end
37
37
  end
@@ -47,24 +47,28 @@ module Bundler
47
47
  # All actions required by the Git source is encapsulated in this
48
48
  # object.
49
49
  class GitProxy
50
- attr_accessor :path, :uri, :ref
50
+ attr_accessor :path, :uri, :branch, :tag, :ref, :explicit_ref
51
51
  attr_writer :revision
52
52
 
53
- def initialize(path, uri, ref, revision = nil, git = nil)
53
+ def initialize(path, uri, options = {}, revision = nil, git = nil)
54
54
  @path = path
55
55
  @uri = uri
56
- @ref = ref
56
+ @branch = options["branch"]
57
+ @tag = options["tag"]
58
+ @ref = options["ref"]
59
+ @explicit_ref = branch || tag || ref
57
60
  @revision = revision
58
61
  @git = git
62
+ @commit_ref = nil
59
63
  end
60
64
 
61
65
  def revision
62
- @revision ||= find_local_revision
66
+ @revision ||= allowed_with_path { find_local_revision }
63
67
  end
64
68
 
65
- def branch
66
- @branch ||= allowed_with_path do
67
- git("rev-parse", "--abbrev-ref", "HEAD", :dir => path).strip
69
+ def current_branch
70
+ @current_branch ||= with_path do
71
+ git_local("rev-parse", "--abbrev-ref", "HEAD", :dir => path).strip
68
72
  end
69
73
  end
70
74
 
@@ -76,36 +80,26 @@ module Bundler
76
80
  end
77
81
 
78
82
  def version
79
- git("--version").match(/(git version\s*)?((\.?\d+)+).*/)[2]
83
+ @version ||= full_version.match(/((\.?\d+)+).*/)[1]
80
84
  end
81
85
 
82
86
  def full_version
83
- git("--version").sub("git version", "").strip
87
+ @full_version ||= git_local("--version").sub(/git version\s*/, "").strip
84
88
  end
85
89
 
86
90
  def checkout
87
- return if path.exist? && has_revision_cached?
88
- extra_ref = "#{ref}:#{ref}" if ref && ref.start_with?("refs/")
89
-
90
- Bundler.ui.info "Fetching #{URICredentialsFilter.credential_filtered_uri(uri)}"
91
+ return if has_revision_cached?
91
92
 
92
- configured_uri = configured_uri_for(uri).to_s
93
+ Bundler.ui.info "Fetching #{credential_filtered_uri}"
93
94
 
94
- unless path.exist?
95
- SharedHelpers.filesystem_access(path.dirname) do |p|
96
- FileUtils.mkdir_p(p)
97
- end
98
- git_retry "clone", "--bare", "--no-hardlinks", "--quiet", "--", configured_uri, path.to_s
99
- return unless extra_ref
100
- end
95
+ extra_fetch_needed = clone_needs_extra_fetch?
96
+ unshallow_needed = clone_needs_unshallow?
97
+ return unless extra_fetch_needed || unshallow_needed
101
98
 
102
- with_path do
103
- git_retry(*["fetch", "--force", "--quiet", "--tags", "--", configured_uri, "refs/heads/*:refs/heads/*", extra_ref].compact, :dir => path)
104
- end
99
+ git_remote_fetch(unshallow_needed ? ["--unshallow"] : depth_args)
105
100
  end
106
101
 
107
102
  def copy_to(destination, submodules = false)
108
- # method 1
109
103
  unless File.exist?(destination.join(".git"))
110
104
  begin
111
105
  SharedHelpers.filesystem_access(destination.dirname) do |p|
@@ -114,7 +108,7 @@ module Bundler
114
108
  SharedHelpers.filesystem_access(destination) do |p|
115
109
  FileUtils.rm_rf(p)
116
110
  end
117
- git_retry "clone", "--no-checkout", "--quiet", path.to_s, destination.to_s
111
+ git "clone", "--no-checkout", "--quiet", path.to_s, destination.to_s
118
112
  File.chmod(((File.stat(destination).mode | 0o777) & ~File.umask), destination)
119
113
  rescue Errno::EEXIST => e
120
114
  file_path = e.message[%r{.*?((?:[a-zA-Z]:)?/.*)}, 1]
@@ -123,14 +117,10 @@ module Bundler
123
117
  "this file and try again."
124
118
  end
125
119
  end
126
- # method 2
127
- git_retry "fetch", "--force", "--quiet", "--tags", path.to_s, :dir => destination
128
120
 
129
- begin
130
- git "reset", "--hard", @revision, :dir => destination
131
- rescue GitCommandError => e
132
- raise MissingGitRevisionError.new(e.command, destination, @revision, URICredentialsFilter.credential_filtered_uri(uri))
133
- end
121
+ git "fetch", "--force", "--quiet", *extra_fetch_args, :dir => destination if @commit_ref
122
+
123
+ git "reset", "--hard", @revision, :dir => destination
134
124
 
135
125
  if submodules
136
126
  git_retry "submodule", "update", "--init", "--recursive", :dir => destination
@@ -142,14 +132,116 @@ module Bundler
142
132
 
143
133
  private
144
134
 
145
- def git_null(*command, dir: nil)
146
- check_allowed(command)
135
+ def git_remote_fetch(args)
136
+ command = ["fetch", "--force", "--quiet", "--no-tags", *args, "--", configured_uri, refspec].compact
137
+ command_with_no_credentials = check_allowed(command)
147
138
 
148
- out, status = SharedHelpers.with_clean_git_env do
149
- capture_and_ignore_stderr(*capture3_args_for(command, dir))
139
+ Bundler::Retry.new("`#{command_with_no_credentials}` at #{path}", [MissingGitRevisionError]).attempts do
140
+ out, err, status = capture(command, path)
141
+ return out if status.success?
142
+
143
+ if err.include?("couldn't find remote ref") || err.include?("not our ref")
144
+ raise MissingGitRevisionError.new(command_with_no_credentials, path, commit || explicit_ref, credential_filtered_uri)
145
+ else
146
+ raise GitCommandError.new(command_with_no_credentials, path, err)
147
+ end
150
148
  end
149
+ end
150
+
151
+ def clone_needs_extra_fetch?
152
+ return true if path.exist?
153
+
154
+ SharedHelpers.filesystem_access(path.dirname) do |p|
155
+ FileUtils.mkdir_p(p)
156
+ end
157
+
158
+ command = ["clone", "--bare", "--no-hardlinks", "--quiet", *extra_clone_args, "--", configured_uri, path.to_s]
159
+ command_with_no_credentials = check_allowed(command)
160
+
161
+ Bundler::Retry.new("`#{command_with_no_credentials}`", [MissingGitRevisionError]).attempts do
162
+ _, err, status = capture(command, nil)
163
+ return extra_ref if status.success?
164
+
165
+ if err.include?("Could not find remote branch")
166
+ raise MissingGitRevisionError.new(command_with_no_credentials, nil, explicit_ref, credential_filtered_uri)
167
+ else
168
+ raise GitCommandError.new(command_with_no_credentials, path, err)
169
+ end
170
+ end
171
+ end
172
+
173
+ def clone_needs_unshallow?
174
+ return false unless path.join("shallow").exist?
175
+ return true if full_clone?
176
+
177
+ @revision && @revision != head_revision
178
+ end
179
+
180
+ def extra_ref
181
+ return false if not_pinned?
182
+ return true unless full_clone?
183
+
184
+ ref.start_with?("refs/")
185
+ end
186
+
187
+ def depth
188
+ return @depth if defined?(@depth)
189
+
190
+ @depth = if !supports_fetching_unreachable_refs?
191
+ nil
192
+ elsif not_pinned? || pinned_to_full_sha?
193
+ 1
194
+ elsif ref.include?("~")
195
+ parsed_depth = ref.split("~").last
196
+ parsed_depth.to_i + 1
197
+ end
198
+ end
199
+
200
+ def refspec
201
+ if commit
202
+ @commit_ref = "refs/#{commit}-sha"
203
+ return "#{commit}:#{@commit_ref}"
204
+ end
205
+
206
+ reference = fully_qualified_ref
207
+
208
+ reference ||= if ref.include?("~")
209
+ ref.split("~").first
210
+ elsif ref.start_with?("refs/")
211
+ ref
212
+ else
213
+ "refs/*"
214
+ end
215
+
216
+ "#{reference}:#{reference}"
217
+ end
218
+
219
+ def commit
220
+ @commit ||= pinned_to_full_sha? ? ref : @revision
221
+ end
222
+
223
+ def fully_qualified_ref
224
+ if branch
225
+ "refs/heads/#{branch}"
226
+ elsif tag
227
+ "refs/tags/#{tag}"
228
+ elsif ref.nil?
229
+ "refs/heads/#{current_branch}"
230
+ end
231
+ end
232
+
233
+ def not_pinned?
234
+ branch || tag || ref.nil?
235
+ end
236
+
237
+ def pinned_to_full_sha?
238
+ ref =~ /\A\h{40}\z/
239
+ end
240
+
241
+ def git_null(*command, dir: nil)
242
+ check_allowed(command)
151
243
 
152
- [URICredentialsFilter.credential_filtered_string(out, uri), status]
244
+ capture(command, dir, :ignore_err => true)
153
245
  end
154
246
 
155
247
  def git_retry(*command, dir: nil)
@@ -161,51 +253,64 @@ module Bundler
161
253
  end
162
254
 
163
255
  def git(*command, dir: nil)
164
- command_with_no_credentials = check_allowed(command)
165
-
166
- out, status = SharedHelpers.with_clean_git_env do
167
- capture_and_filter_stderr(*capture3_args_for(command, dir))
256
+ run_command(*command, :dir => dir) do |unredacted_command|
257
+ check_allowed(unredacted_command)
168
258
  end
259
+ end
169
260
 
170
- filtered_out = URICredentialsFilter.credential_filtered_string(out, uri)
171
-
172
- raise GitCommandError.new(command_with_no_credentials, dir || SharedHelpers.pwd, filtered_out) unless status.success?
173
-
174
- filtered_out
261
+ def git_local(*command, dir: nil)
262
+ run_command(*command, :dir => dir) do |unredacted_command|
263
+ redact_and_check_presence(unredacted_command)
264
+ end
175
265
  end
176
266
 
177
267
  def has_revision_cached?
178
- return unless @revision
179
- with_path { git("cat-file", "-e", @revision, :dir => path) }
268
+ return unless @revision && path.exist?
269
+ git("cat-file", "-e", @revision, :dir => path)
180
270
  true
181
271
  rescue GitError
182
272
  false
183
273
  end
184
274
 
185
- def remove_cache
186
- FileUtils.rm_rf(path)
275
+ def find_local_revision
276
+ return head_revision if explicit_ref.nil?
277
+
278
+ find_revision_for(explicit_ref)
187
279
  end
188
280
 
189
- def find_local_revision
190
- allowed_with_path do
191
- git("rev-parse", "--verify", ref || "HEAD", :dir => path).strip
192
- end
281
+ def head_revision
282
+ verify("HEAD")
283
+ end
284
+
285
+ def find_revision_for(reference)
286
+ verify(reference)
193
287
  rescue GitCommandError => e
194
- raise MissingGitRevisionError.new(e.command, path, ref, URICredentialsFilter.credential_filtered_uri(uri))
288
+ raise MissingGitRevisionError.new(e.command, path, reference, credential_filtered_uri)
289
+ end
290
+
291
+ def verify(reference)
292
+ git("rev-parse", "--verify", reference, :dir => path).strip
195
293
  end
196
294
 
197
- # Adds credentials to the URI as Fetcher#configured_uri_for does
198
- def configured_uri_for(uri)
199
- if /https?:/ =~ uri
295
+ # Adds credentials to the URI
296
+ def configured_uri
297
+ if /https?:/.match?(uri)
200
298
  remote = Bundler::URI(uri)
201
299
  config_auth = Bundler.settings[remote.to_s] || Bundler.settings[remote.host]
202
300
  remote.userinfo ||= config_auth
203
301
  remote.to_s
302
+ elsif File.exist?(uri)
303
+ "file://#{uri}"
204
304
  else
205
- uri
305
+ uri.to_s
206
306
  end
207
307
  end
208
308
 
309
+ # Removes credentials from the URI
310
+ def credential_filtered_uri
311
+ URICredentialsFilter.credential_filtered_uri(uri)
312
+ end
313
+
209
314
  def allow?
210
315
  allowed = @git ? @git.allow_git_ops? : true
211
316
 
@@ -225,23 +330,41 @@ module Bundler
225
330
  end
226
331
 
227
332
  def check_allowed(command)
228
- require "shellwords"
229
- command_with_no_credentials = URICredentialsFilter.credential_filtered_string("git #{command.shelljoin}", uri)
333
+ command_with_no_credentials = redact_and_check_presence(command)
230
334
  raise GitNotAllowedError.new(command_with_no_credentials) unless allow?
231
335
  command_with_no_credentials
232
336
  end
233
337
 
234
- def capture_and_filter_stderr(*cmd)
235
- require "open3"
236
- return_value, captured_err, status = Open3.capture3(*cmd)
237
- Bundler.ui.warn URICredentialsFilter.credential_filtered_string(captured_err, uri) unless captured_err.empty?
238
- [return_value, status]
338
+ def redact_and_check_presence(command)
339
+ raise GitNotInstalledError.new unless Bundler.git_present?
340
+
341
+ require "shellwords"
342
+ URICredentialsFilter.credential_filtered_string("git #{command.shelljoin}", uri)
239
343
  end
240
344
 
241
- def capture_and_ignore_stderr(*cmd)
242
- require "open3"
243
- return_value, _, status = Open3.capture3(*cmd)
244
- [return_value, status]
345
+ def run_command(*command, dir: nil)
346
+ command_with_no_credentials = yield(command)
347
+
348
+ out, err, status = capture(command, dir)
349
+
350
+ raise GitCommandError.new(command_with_no_credentials, dir || SharedHelpers.pwd, err) unless status.success?
351
+
352
+ Bundler.ui.warn err unless err.empty?
353
+
354
+ out
355
+ end
356
+
357
+ def capture(cmd, dir, ignore_err: false)
358
+ SharedHelpers.with_clean_git_env do
359
+ require "open3"
360
+ out, err, status = Open3.capture3(*capture3_args_for(cmd, dir))
361
+
362
+ filtered_out = URICredentialsFilter.credential_filtered_string(out, uri)
363
+ return [filtered_out, status] if ignore_err
364
+
365
+ filtered_err = URICredentialsFilter.credential_filtered_string(err, uri)
366
+ [filtered_out, filtered_err, status]
367
+ end
245
368
  end
246
369
 
247
370
  def capture3_args_for(cmd, dir)
@@ -254,9 +377,49 @@ module Bundler
254
377
  end
255
378
  end
256
379
 
380
+ def extra_clone_args
381
+ args = depth_args
382
+ return [] if args.empty?
383
+
384
+ args += ["--single-branch"]
385
+ args.unshift("--no-tags") if supports_cloning_with_no_tags?
386
+
387
+ # If there's a locked revision, no need to clone any specific branch
388
+ # or tag, since we will end up checking out that locked revision
389
+ # anyways.
390
+ return args if @revision
391
+
392
+ args += ["--branch", branch || tag] if branch || tag
393
+ args
394
+ end
395
+
396
+ def depth_args
397
+ return [] if full_clone?
398
+
399
+ ["--depth", depth.to_s]
400
+ end
401
+
402
+ def extra_fetch_args
403
+ extra_args = [path.to_s, *depth_args]
404
+ extra_args.push(@commit_ref)
405
+ extra_args
406
+ end
407
+
408
+ def full_clone?
409
+ depth.nil?
410
+ end
411
+
257
412
  def supports_minus_c?
258
413
  @supports_minus_c ||= Gem::Version.new(version) >= Gem::Version.new("1.8.5")
259
414
  end
415
+
416
+ def supports_fetching_unreachable_refs?
417
+ @supports_fetching_unreachable_refs ||= Gem::Version.new(version) >= Gem::Version.new("2.5.0")
418
+ end
419
+
420
+ def supports_cloning_with_no_tags?
421
+ @supports_cloning_with_no_tags ||= Gem::Version.new(version) >= Gem::Version.new("2.14.0-rc0")
422
+ end
260
423
  end
261
424
  end
262
425
  end
@@ -19,7 +19,7 @@ module Bundler
19
19
  # Stringify options that could be set as symbols
20
20
  %w[ref branch tag revision].each {|k| options[k] = options[k].to_s if options[k] }
21
21
 
22
- @uri = options["uri"] || ""
22
+ @uri = URINormalizer.normalize_suffix(options["uri"] || "", :trailing_slash => false)
23
23
  @safe_uri = URICredentialsFilter.credential_filtered_uri(@uri)
24
24
  @branch = options["branch"]
25
25
  @ref = options["ref"] || options["branch"] || options["tag"]
@@ -46,6 +46,14 @@ module Bundler
46
46
  out << " specs:\n"
47
47
  end
48
48
 
49
+ def to_gemfile
50
+ specifiers = %w[ref branch tag submodules glob].map do |opt|
51
+ "#{opt}: #{options[opt]}" if options[opt]
52
+ end
53
+
54
+ uri_with_specifiers(specifiers)
55
+ end
56
+
49
57
  def hash
50
58
  [self.class, uri, ref, branch, name, version, glob, submodules].hash
51
59
  end
@@ -61,26 +69,23 @@ module Bundler
61
69
 
62
70
  def to_s
63
71
  begin
64
- at = if local?
65
- path
66
- elsif user_ref = options["ref"]
67
- if ref =~ /\A[a-z0-9]{4,}\z/i
68
- shortref_for_display(user_ref)
69
- else
70
- user_ref
71
- end
72
- elsif ref
73
- ref
74
- else
75
- git_proxy.branch
76
- end
72
+ at = humanized_ref || current_branch
77
73
 
78
74
  rev = "at #{at}@#{shortref_for_display(revision)}"
79
75
  rescue GitError
80
76
  ""
81
77
  end
82
78
 
83
- specifiers = [rev, glob_for_display].compact
79
+ uri_with_specifiers([rev, glob_for_display])
80
+ end
81
+
82
+ def identifier
83
+ uri_with_specifiers([humanized_ref, cached_revision, glob_for_display])
84
+ end
85
+
86
+ def uri_with_specifiers(specifiers)
87
+ specifiers.compact!
88
+
84
89
  suffix =
85
90
  if specifiers.any?
86
91
  " (#{specifiers.join(", ")})"
@@ -102,13 +107,7 @@ module Bundler
102
107
  @install_path ||= begin
103
108
  git_scope = "#{base_name}-#{shortref_for_path(revision)}"
104
109
 
105
- path = Bundler.install_path.join(git_scope)
106
-
107
- if !path.exist? && Bundler.requires_sudo?
108
- Bundler.user_bundle_path.join(Bundler.ruby_scope).join(git_scope)
109
- else
110
- path
111
- end
110
+ Bundler.install_path.join(git_scope)
112
111
  end
113
112
  end
114
113
 
@@ -132,7 +131,7 @@ module Bundler
132
131
  path = Pathname.new(path)
133
132
  path = path.expand_path(Bundler.root) unless path.relative?
134
133
 
135
- unless options["branch"] || Bundler.settings[:disable_local_branch_check]
134
+ unless branch || Bundler.settings[:disable_local_branch_check]
136
135
  raise GitError, "Cannot use local override for #{name} at #{path} because " \
137
136
  ":branch is not specified in Gemfile. Specify a branch or run " \
138
137
  "`bundle config unset local.#{override_for(original_path)}` to remove the local override"
@@ -147,14 +146,14 @@ module Bundler
147
146
 
148
147
  # Create a new git proxy without the cached revision
149
148
  # so the Gemfile.lock always picks up the new revision.
150
- @git_proxy = GitProxy.new(path, uri, ref)
149
+ @git_proxy = GitProxy.new(path, uri, options)
151
150
 
152
- if git_proxy.branch != options["branch"] && !Bundler.settings[:disable_local_branch_check]
151
+ if current_branch != branch && !Bundler.settings[:disable_local_branch_check]
153
152
  raise GitError, "Local override for #{name} at #{path} is using branch " \
154
- "#{git_proxy.branch} but Gemfile specifies #{options["branch"]}"
153
+ "#{current_branch} but Gemfile specifies #{branch}"
155
154
  end
156
155
 
157
- changed = cached_revision && cached_revision != git_proxy.revision
156
+ changed = cached_revision && cached_revision != revision
158
157
 
159
158
  if !Bundler.settings[:disable_local_revision_check] && changed && !@unlocked && !git_proxy.contains?(cached_revision)
160
159
  raise GitError, "The Gemfile lock is pointing to revision #{shortref_for_display(cached_revision)} " \
@@ -179,9 +178,10 @@ module Bundler
179
178
  end
180
179
 
181
180
  def install(spec, options = {})
181
+ return if Bundler.settings[:no_install]
182
182
  force = options[:force]
183
183
 
184
- print_using_message "Using #{version_message(spec)} from #{self}"
184
+ print_using_message "Using #{version_message(spec, options[:previous_spec])} from #{self}"
185
185
 
186
186
  if (requires_checkout? && !@copied) || force
187
187
  Bundler.ui.debug " * Checking out revision: #{ref}"
@@ -219,13 +219,11 @@ module Bundler
219
219
  # across different projects, this cache will be shared.
220
220
  # When using local git repos, this is set to the local repo.
221
221
  def cache_path
222
- @cache_path ||= begin
223
- if Bundler.requires_sudo? || Bundler.feature_flag.global_gem_cache?
224
- Bundler.user_cache
225
- else
226
- Bundler.bundle_path.join("cache", "bundler")
227
- end.join("git", git_scope)
228
- end
222
+ @cache_path ||= if Bundler.feature_flag.global_gem_cache?
223
+ Bundler.user_cache
224
+ else
225
+ Bundler.bundle_path.join("cache", "bundler")
226
+ end.join("git", git_scope)
229
227
  end
230
228
 
231
229
  def app_cache_dirname
@@ -236,6 +234,10 @@ module Bundler
236
234
  git_proxy.revision
237
235
  end
238
236
 
237
+ def current_branch
238
+ git_proxy.current_branch
239
+ end
240
+
239
241
  def allow_git_ops?
240
242
  @allow_remote || @allow_cached
241
243
  end
@@ -246,6 +248,20 @@ module Bundler
246
248
 
247
249
  private
248
250
 
251
+ def humanized_ref
252
+ if local?
253
+ path
254
+ elsif user_ref = options["ref"]
255
+ if /\A[a-z0-9]{4,}\z/i.match?(ref)
256
+ shortref_for_display(user_ref)
257
+ else
258
+ user_ref
259
+ end
260
+ elsif ref
261
+ ref
262
+ end
263
+ end
264
+
249
265
  def serialize_gemspecs_in(destination)
250
266
  destination = destination.expand_path(Bundler.root) if destination.relative?
251
267
  Dir["#{destination}/#{@glob}"].each do |spec_path|
@@ -299,7 +315,7 @@ module Bundler
299
315
  end
300
316
 
301
317
  def uri_hash
302
- if uri =~ %r{^\w+://(\w+@)?}
318
+ if %r{^\w+://(\w+@)?}.match?(uri)
303
319
  # Downcase the domain component of the URI
304
320
  # and strip off a trailing slash, if one is present
305
321
  input = Bundler::URI.parse(uri).normalize.to_s.sub(%r{/$}, "")
@@ -321,7 +337,7 @@ module Bundler
321
337
  end
322
338
 
323
339
  def git_proxy
324
- @git_proxy ||= GitProxy.new(cache_path, uri, ref, cached_revision, self)
340
+ @git_proxy ||= GitProxy.new(cache_path, uri, options, cached_revision, self)
325
341
  end
326
342
 
327
343
  def fetch
@@ -336,7 +352,7 @@ module Bundler
336
352
 
337
353
  def load_gemspec(file)
338
354
  stub = Gem::StubSpecification.gemspec_stub(file, install_path.parent, install_path.parent)
339
- stub.full_gem_path = Pathname.new(file).dirname.expand_path(root).to_s.tap{|x| x.untaint if RUBY_VERSION < "2.7" }
355
+ stub.full_gem_path = Pathname.new(file).dirname.expand_path(root).to_s.tap {|x| x.untaint if RUBY_VERSION < "2.7" }
340
356
  StubSpecification.from_stub(stub)
341
357
  end
342
358
 
@@ -5,7 +5,7 @@ module Bundler
5
5
  class Metadata < Source
6
6
  def specs
7
7
  @specs ||= Index.build do |idx|
8
- idx << Gem::Specification.new("Ruby\0", RubyVersion.system.to_gem_version_with_patchlevel)
8
+ idx << Gem::Specification.new("Ruby\0", Gem.ruby_version)
9
9
  idx << Gem::Specification.new("RubyGems\0", Gem::VERSION) do |s|
10
10
  s.required_rubygems_version = Gem::Requirement.default
11
11
  end
@@ -15,17 +15,16 @@ module Bundler
15
15
  s.version = VERSION
16
16
  s.license = "MIT"
17
17
  s.platform = Gem::Platform::RUBY
18
- s.source = self
19
18
  s.authors = ["bundler team"]
20
19
  s.bindir = "exe"
21
20
  s.homepage = "https://bundler.io"
22
21
  s.summary = "The best way to manage your application's dependencies"
23
22
  s.executables = %w[bundle]
24
23
  # can't point to the actual gemspec or else the require paths will be wrong
25
- s.loaded_from = File.expand_path("..", __FILE__)
24
+ s.loaded_from = __dir__
26
25
  end
27
26
 
28
- if local_spec = Bundler.rubygems.find_name("bundler").find {|s| s.version.to_s == VERSION }
27
+ if local_spec = Bundler.rubygems.find_bundler(VERSION)
29
28
  idx << local_spec
30
29
  end
31
30