rubygems-update 2.6.14 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubygems-update might be problematic. Click here for more details.

Files changed (347) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +10 -7
  3. data/CONTRIBUTING.rdoc +53 -54
  4. data/History.txt +173 -9
  5. data/Manifest.txt +39 -11
  6. data/POLICIES.rdoc +3 -3
  7. data/README.md +72 -0
  8. data/Rakefile +30 -5
  9. data/appveyor.yml +29 -1
  10. data/bin/gem +1 -1
  11. data/bin/update_rubygems +2 -2
  12. data/bundler/CHANGELOG.md +269 -9
  13. data/bundler/CODE_OF_CONDUCT.md +1 -1
  14. data/bundler/CONTRIBUTING.md +10 -29
  15. data/bundler/README.md +22 -10
  16. data/bundler/exe/bundle +5 -7
  17. data/bundler/exe/bundle_ruby +4 -3
  18. data/bundler/lib/bundler.rb +94 -74
  19. data/bundler/lib/bundler/build_metadata.rb +36 -0
  20. data/bundler/lib/bundler/capistrano.rb +5 -0
  21. data/bundler/lib/bundler/cli.rb +229 -66
  22. data/bundler/lib/bundler/cli/add.rb +25 -0
  23. data/bundler/lib/bundler/cli/binstubs.rb +9 -7
  24. data/bundler/lib/bundler/cli/cache.rb +5 -4
  25. data/bundler/lib/bundler/cli/check.rb +3 -5
  26. data/bundler/lib/bundler/cli/clean.rb +5 -6
  27. data/bundler/lib/bundler/cli/common.rb +18 -2
  28. data/bundler/lib/bundler/cli/config.rb +26 -7
  29. data/bundler/lib/bundler/cli/console.rb +2 -1
  30. data/bundler/lib/bundler/cli/doctor.rb +1 -0
  31. data/bundler/lib/bundler/cli/exec.rb +3 -2
  32. data/bundler/lib/bundler/cli/gem.rb +36 -15
  33. data/bundler/lib/bundler/cli/info.rb +50 -0
  34. data/bundler/lib/bundler/cli/init.rb +20 -7
  35. data/bundler/lib/bundler/cli/inject.rb +13 -4
  36. data/bundler/lib/bundler/cli/install.rb +61 -77
  37. data/bundler/lib/bundler/cli/issue.rb +40 -0
  38. data/bundler/lib/bundler/cli/list.rb +22 -0
  39. data/bundler/lib/bundler/cli/lock.rb +4 -2
  40. data/bundler/lib/bundler/cli/open.rb +2 -2
  41. data/bundler/lib/bundler/cli/outdated.rb +30 -28
  42. data/bundler/lib/bundler/cli/package.rb +9 -6
  43. data/bundler/lib/bundler/cli/platform.rb +1 -0
  44. data/bundler/lib/bundler/cli/plugin.rb +1 -0
  45. data/bundler/lib/bundler/cli/pristine.rb +43 -0
  46. data/bundler/lib/bundler/cli/show.rb +1 -1
  47. data/bundler/lib/bundler/cli/update.rb +32 -11
  48. data/bundler/lib/bundler/cli/viz.rb +5 -1
  49. data/bundler/lib/bundler/compact_index_client.rb +1 -0
  50. data/bundler/lib/bundler/compact_index_client/cache.rb +1 -2
  51. data/bundler/lib/bundler/compact_index_client/updater.rb +26 -7
  52. data/bundler/lib/bundler/compatibility_guard.rb +14 -0
  53. data/bundler/lib/bundler/constants.rb +1 -0
  54. data/bundler/lib/bundler/current_ruby.rb +8 -7
  55. data/bundler/lib/bundler/definition.rb +231 -159
  56. data/bundler/lib/bundler/dep_proxy.rb +2 -0
  57. data/bundler/lib/bundler/dependency.rb +6 -7
  58. data/bundler/lib/bundler/deployment.rb +1 -1
  59. data/bundler/lib/bundler/deprecate.rb +14 -3
  60. data/bundler/lib/bundler/dsl.rb +103 -62
  61. data/bundler/lib/bundler/endpoint_specification.rb +12 -2
  62. data/bundler/lib/bundler/env.rb +97 -36
  63. data/bundler/lib/bundler/environment_preserver.rb +27 -6
  64. data/bundler/lib/bundler/errors.rb +3 -1
  65. data/bundler/lib/bundler/feature_flag.rb +39 -4
  66. data/bundler/lib/bundler/fetcher.rb +15 -8
  67. data/bundler/lib/bundler/fetcher/base.rb +1 -0
  68. data/bundler/lib/bundler/fetcher/compact_index.rb +2 -12
  69. data/bundler/lib/bundler/fetcher/dependency.rb +2 -1
  70. data/bundler/lib/bundler/fetcher/downloader.rb +4 -2
  71. data/bundler/lib/bundler/fetcher/index.rb +1 -0
  72. data/bundler/lib/bundler/friendly_errors.rb +5 -2
  73. data/bundler/lib/bundler/gem_helper.rb +23 -9
  74. data/bundler/lib/bundler/gem_helpers.rb +1 -0
  75. data/bundler/lib/bundler/gem_remote_fetcher.rb +1 -0
  76. data/bundler/lib/bundler/gem_tasks.rb +1 -0
  77. data/bundler/lib/bundler/gem_version_promoter.rb +1 -0
  78. data/bundler/lib/bundler/gemdeps.rb +1 -0
  79. data/bundler/lib/bundler/graph.rb +1 -0
  80. data/bundler/lib/bundler/index.rb +19 -11
  81. data/bundler/lib/bundler/injector.rb +51 -27
  82. data/bundler/lib/bundler/inline.rb +10 -10
  83. data/bundler/lib/bundler/installer.rb +104 -50
  84. data/bundler/lib/bundler/installer/gem_installer.rb +5 -2
  85. data/bundler/lib/bundler/installer/parallel_installer.rb +91 -42
  86. data/bundler/lib/bundler/installer/standalone.rb +1 -0
  87. data/bundler/lib/bundler/lazy_specification.rb +17 -4
  88. data/bundler/lib/bundler/lockfile_generator.rb +95 -0
  89. data/bundler/lib/bundler/lockfile_parser.rb +49 -35
  90. data/bundler/lib/bundler/match_platform.rb +1 -0
  91. data/bundler/lib/bundler/mirror.rb +8 -3
  92. data/bundler/lib/bundler/plugin.rb +6 -1
  93. data/bundler/lib/bundler/plugin/api/source.rb +16 -3
  94. data/bundler/lib/bundler/plugin/index.rb +2 -0
  95. data/bundler/lib/bundler/plugin/installer.rb +7 -6
  96. data/bundler/lib/bundler/plugin/source_list.rb +7 -8
  97. data/bundler/lib/bundler/process_lock.rb +24 -0
  98. data/bundler/lib/bundler/psyched_yaml.rb +10 -0
  99. data/bundler/lib/bundler/remote_specification.rb +25 -1
  100. data/bundler/lib/bundler/resolver.rb +171 -192
  101. data/bundler/lib/bundler/resolver/spec_group.rb +111 -0
  102. data/bundler/lib/bundler/retry.rb +1 -0
  103. data/bundler/lib/bundler/ruby_dsl.rb +1 -0
  104. data/bundler/lib/bundler/ruby_version.rb +6 -1
  105. data/bundler/lib/bundler/rubygems_ext.rb +18 -8
  106. data/bundler/lib/bundler/rubygems_gem_installer.rb +25 -2
  107. data/bundler/lib/bundler/rubygems_integration.rb +157 -66
  108. data/bundler/lib/bundler/runtime.rb +28 -18
  109. data/bundler/lib/bundler/settings.rb +202 -87
  110. data/bundler/lib/bundler/settings/validator.rb +79 -0
  111. data/bundler/lib/bundler/setup.rb +4 -7
  112. data/bundler/lib/bundler/shared_helpers.rb +129 -25
  113. data/bundler/lib/bundler/similarity_detector.rb +1 -0
  114. data/bundler/lib/bundler/source.rb +53 -1
  115. data/bundler/lib/bundler/source/gemspec.rb +1 -0
  116. data/bundler/lib/bundler/source/git.rb +49 -21
  117. data/bundler/lib/bundler/source/git/git_proxy.rb +17 -12
  118. data/bundler/lib/bundler/source/metadata.rb +63 -0
  119. data/bundler/lib/bundler/source/path.rb +38 -17
  120. data/bundler/lib/bundler/source/path/installer.rb +4 -2
  121. data/bundler/lib/bundler/source/rubygems.rb +154 -82
  122. data/bundler/lib/bundler/source/rubygems/remote.rb +8 -1
  123. data/bundler/lib/bundler/source_list.rb +75 -15
  124. data/bundler/lib/bundler/spec_set.rb +34 -21
  125. data/bundler/lib/bundler/ssl_certs/certificate_manager.rb +2 -1
  126. data/bundler/lib/bundler/stub_specification.rb +86 -2
  127. data/bundler/lib/bundler/templates/Executable +5 -1
  128. data/bundler/lib/bundler/templates/Executable.bundler +105 -0
  129. data/bundler/lib/bundler/templates/Executable.standalone +5 -5
  130. data/bundler/lib/bundler/templates/Gemfile +3 -0
  131. data/bundler/lib/bundler/templates/gems.rb +8 -0
  132. data/bundler/lib/bundler/templates/newgem/Gemfile.tt +4 -2
  133. data/bundler/lib/bundler/templates/newgem/LICENSE.txt.tt +1 -1
  134. data/bundler/lib/bundler/templates/newgem/README.md.tt +14 -8
  135. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +5 -5
  136. data/bundler/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +4 -4
  137. data/bundler/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +3 -3
  138. data/bundler/lib/bundler/templates/newgem/gitignore.tt +0 -1
  139. data/bundler/lib/bundler/templates/newgem/lib/newgem.rb.tt +6 -6
  140. data/bundler/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +4 -4
  141. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +13 -10
  142. data/bundler/lib/bundler/templates/newgem/rspec.tt +1 -0
  143. data/bundler/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +0 -2
  144. data/bundler/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +3 -0
  145. data/bundler/lib/bundler/templates/newgem/test/newgem_test.rb.tt +1 -1
  146. data/bundler/lib/bundler/templates/newgem/test/test_helper.rb.tt +3 -3
  147. data/bundler/lib/bundler/ui.rb +1 -0
  148. data/bundler/lib/bundler/ui/rg_proxy.rb +1 -0
  149. data/bundler/lib/bundler/ui/shell.rb +24 -10
  150. data/bundler/lib/bundler/ui/silent.rb +12 -1
  151. data/bundler/lib/bundler/uri_credentials_filter.rb +1 -0
  152. data/bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb +1638 -0
  153. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo.rb +2 -0
  154. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +26 -0
  155. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +7 -0
  156. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +1 -0
  157. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +16 -5
  158. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +1 -0
  159. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +10 -2
  160. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +1 -0
  161. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +1 -0
  162. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -0
  163. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +1 -0
  164. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +1 -0
  165. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +1 -0
  166. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +5 -4
  167. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +69 -6
  168. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +2 -1
  169. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +1 -0
  170. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +3 -1
  171. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +501 -138
  172. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +1 -0
  173. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +8 -4
  174. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +3 -1
  175. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +46 -21
  176. data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +24 -22
  177. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +2 -1
  178. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +2 -1
  179. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +2 -2
  180. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +16 -8
  181. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +66 -18
  182. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +17 -15
  183. data/bundler/lib/bundler/vendor/thor/lib/thor/base.rb +55 -32
  184. data/bundler/lib/bundler/vendor/thor/lib/thor/command.rb +13 -11
  185. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +21 -1
  186. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +7 -5
  187. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +94 -63
  188. data/bundler/lib/bundler/vendor/thor/lib/thor/error.rb +3 -3
  189. data/bundler/lib/bundler/vendor/thor/lib/thor/group.rb +13 -13
  190. data/bundler/lib/bundler/vendor/thor/lib/thor/invocation.rb +4 -5
  191. data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +2 -0
  192. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +4 -7
  193. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +16 -16
  194. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb +42 -21
  195. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +13 -10
  196. data/bundler/lib/bundler/vendor/thor/lib/thor/runner.rb +31 -29
  197. data/bundler/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  198. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +49 -33
  199. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/color.rb +1 -1
  200. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/html.rb +4 -4
  201. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +8 -7
  202. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  203. data/bundler/lib/bundler/vendored_fileutils.rb +9 -0
  204. data/bundler/lib/bundler/vendored_molinillo.rb +1 -0
  205. data/bundler/lib/bundler/vendored_persistent.rb +35 -0
  206. data/bundler/lib/bundler/vendored_thor.rb +6 -2
  207. data/bundler/lib/bundler/version.rb +19 -2
  208. data/bundler/lib/bundler/version_ranges.rb +76 -0
  209. data/bundler/lib/bundler/vlad.rb +5 -0
  210. data/bundler/lib/bundler/worker.rb +3 -1
  211. data/bundler/lib/bundler/yaml_serializer.rb +3 -3
  212. data/bundler/man/bundle-add.ronn +29 -0
  213. data/bundler/man/bundle-binstubs.ronn +14 -0
  214. data/bundler/man/bundle-check.ronn +26 -0
  215. data/bundler/man/bundle-clean.ronn +18 -0
  216. data/bundler/man/bundle-config.ronn +180 -60
  217. data/bundler/man/bundle-exec.ronn +7 -0
  218. data/bundler/man/bundle-gem.ronn +3 -2
  219. data/bundler/man/bundle-info.ronn +17 -0
  220. data/bundler/man/bundle-init.ronn +18 -0
  221. data/bundler/man/bundle-inject.ronn +22 -0
  222. data/bundler/man/bundle-install.ronn +32 -32
  223. data/bundler/man/bundle-list.ronn +15 -0
  224. data/bundler/man/bundle-open.ronn +19 -0
  225. data/bundler/man/bundle-outdated.ronn +1 -1
  226. data/bundler/man/bundle-package.ronn +5 -0
  227. data/bundler/man/bundle-pristine.ronn +34 -0
  228. data/bundler/man/bundle-show.ronn +20 -0
  229. data/bundler/man/bundle-update.ronn +6 -3
  230. data/bundler/man/bundle-viz.ronn +30 -0
  231. data/bundler/man/bundle.ronn +11 -20
  232. data/bundler/man/gemfile.5.ronn +55 -64
  233. data/lib/rubygems.rb +79 -36
  234. data/lib/rubygems/basic_specification.rb +8 -4
  235. data/lib/rubygems/bundler_version_finder.rb +112 -0
  236. data/lib/rubygems/command.rb +1 -1
  237. data/lib/rubygems/command_manager.rb +3 -1
  238. data/lib/rubygems/commands/cert_command.rb +31 -6
  239. data/lib/rubygems/commands/cleanup_command.rb +1 -1
  240. data/lib/rubygems/commands/help_command.rb +1 -1
  241. data/lib/rubygems/commands/owner_command.rb +3 -1
  242. data/lib/rubygems/commands/pristine_command.rb +11 -8
  243. data/lib/rubygems/commands/push_command.rb +2 -1
  244. data/lib/rubygems/commands/query_command.rb +13 -14
  245. data/lib/rubygems/commands/setup_command.rb +124 -69
  246. data/lib/rubygems/commands/signin_command.rb +33 -0
  247. data/lib/rubygems/commands/signout_command.rb +33 -0
  248. data/lib/rubygems/commands/uninstall_command.rb +4 -3
  249. data/lib/rubygems/commands/unpack_command.rb +16 -4
  250. data/lib/rubygems/commands/update_command.rb +1 -1
  251. data/lib/rubygems/commands/which_command.rb +1 -1
  252. data/lib/rubygems/commands/yank_command.rb +4 -11
  253. data/lib/rubygems/config_file.rb +13 -24
  254. data/lib/rubygems/core_ext/kernel_require.rb +10 -9
  255. data/lib/rubygems/dependency.rb +2 -0
  256. data/lib/rubygems/dependency_installer.rb +4 -0
  257. data/lib/rubygems/errors.rb +3 -0
  258. data/lib/rubygems/exceptions.rb +6 -0
  259. data/lib/rubygems/ext/builder.rb +1 -1
  260. data/lib/rubygems/ext/ext_conf_builder.rb +2 -4
  261. data/lib/rubygems/ext/rake_builder.rb +1 -1
  262. data/lib/rubygems/gem_runner.rb +5 -1
  263. data/lib/rubygems/install_update_options.rb +5 -28
  264. data/lib/rubygems/installer.rb +12 -7
  265. data/lib/rubygems/installer_test_case.rb +6 -3
  266. data/lib/rubygems/package/old.rb +1 -1
  267. data/lib/rubygems/request.rb +1 -1
  268. data/lib/rubygems/request_set.rb +20 -3
  269. data/lib/rubygems/request_set/gem_dependency_api.rb +3 -3
  270. data/lib/rubygems/requirement.rb +5 -1
  271. data/lib/rubygems/resolver.rb +24 -3
  272. data/lib/rubygems/resolver/installer_set.rb +4 -6
  273. data/lib/rubygems/safe_yaml.rb +4 -1
  274. data/lib/rubygems/security.rb +10 -3
  275. data/lib/rubygems/security_option.rb +43 -0
  276. data/lib/rubygems/server.rb +4 -12
  277. data/lib/rubygems/source.rb +7 -4
  278. data/lib/rubygems/source/git.rb +2 -1
  279. data/lib/rubygems/source/local.rb +38 -35
  280. data/lib/rubygems/source/lock.rb +4 -1
  281. data/lib/rubygems/source_local.rb +3 -1
  282. data/lib/rubygems/source_specific_file.rb +3 -2
  283. data/lib/rubygems/spec_fetcher.rb +7 -3
  284. data/lib/rubygems/specification.rb +281 -231
  285. data/lib/rubygems/stub_specification.rb +2 -3
  286. data/lib/rubygems/test_case.rb +14 -1
  287. data/lib/rubygems/user_interaction.rb +15 -13
  288. data/lib/rubygems/util.rb +6 -17
  289. data/lib/rubygems/version.rb +17 -3
  290. data/lib/rubygems/version_option.rb +6 -1
  291. data/setup.rb +1 -1
  292. data/test/rubygems/private3072_key.pem +40 -0
  293. data/test/rubygems/public3072_cert.pem +25 -0
  294. data/test/rubygems/test_config.rb +1 -1
  295. data/test/rubygems/test_gem.rb +72 -14
  296. data/test/rubygems/test_gem_bundler_version_finder.rb +125 -0
  297. data/test/rubygems/test_gem_command.rb +1 -1
  298. data/test/rubygems/test_gem_commands_build_command.rb +27 -1
  299. data/test/rubygems/test_gem_commands_cert_command.rb +64 -0
  300. data/test/rubygems/test_gem_commands_install_command.rb +35 -2
  301. data/test/rubygems/test_gem_commands_pristine_command.rb +1 -1
  302. data/test/rubygems/test_gem_commands_query_command.rb +19 -0
  303. data/test/rubygems/test_gem_commands_setup_command.rb +17 -0
  304. data/test/rubygems/test_gem_commands_signin_command.rb +95 -0
  305. data/test/rubygems/test_gem_commands_signout_command.rb +37 -0
  306. data/test/rubygems/test_gem_commands_sources_command.rb +1 -1
  307. data/test/rubygems/test_gem_commands_uninstall_command.rb +12 -0
  308. data/test/rubygems/test_gem_commands_update_command.rb +1 -1
  309. data/test/rubygems/test_gem_commands_which_command.rb +3 -3
  310. data/test/rubygems/test_gem_dependency.rb +28 -0
  311. data/test/rubygems/test_gem_ext_builder.rb +2 -2
  312. data/test/rubygems/test_gem_ext_rake_builder.rb +2 -2
  313. data/test/rubygems/test_gem_install_update_options.rb +2 -1
  314. data/test/rubygems/test_gem_installer.rb +29 -27
  315. data/test/rubygems/test_gem_package.rb +5 -5
  316. data/test/rubygems/test_gem_remote_fetcher.rb +2 -2
  317. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +3 -3
  318. data/test/rubygems/test_gem_requirement.rb +6 -0
  319. data/test/rubygems/test_gem_resolver.rb +26 -0
  320. data/test/rubygems/test_gem_resolver_conflict.rb +1 -1
  321. data/test/rubygems/test_gem_security.rb +5 -0
  322. data/test/rubygems/test_gem_security_policy.rb +24 -24
  323. data/test/rubygems/test_gem_security_signer.rb +6 -6
  324. data/test/rubygems/test_gem_security_trust_dir.rb +2 -2
  325. data/test/rubygems/test_gem_server.rb +18 -1
  326. data/test/rubygems/test_gem_source.rb +9 -0
  327. data/test/rubygems/test_gem_spec_fetcher.rb +20 -0
  328. data/test/rubygems/test_gem_specification.rb +85 -10
  329. data/test/rubygems/test_gem_stream_ui.rb +6 -6
  330. data/test/rubygems/test_gem_stub_specification.rb +19 -1
  331. data/test/rubygems/test_gem_util.rb +1 -0
  332. data/test/rubygems/test_gem_version.rb +28 -7
  333. data/test/rubygems/test_gem_version_option.rb +15 -0
  334. data/test/rubygems/test_kernel.rb +30 -0
  335. data/test/rubygems/test_require.rb +44 -0
  336. metadata +47 -46
  337. data/README.rdoc +0 -54
  338. data/bundler/DEVELOPMENT.md +0 -150
  339. data/bundler/ISSUES.md +0 -117
  340. data/bundler/lib/bundler/postit_trampoline.rb +0 -73
  341. data/bundler/lib/bundler/vendor/postit/lib/postit.rb +0 -15
  342. data/bundler/lib/bundler/vendor/postit/lib/postit/environment.rb +0 -44
  343. data/bundler/lib/bundler/vendor/postit/lib/postit/installer.rb +0 -28
  344. data/bundler/lib/bundler/vendor/postit/lib/postit/parser.rb +0 -21
  345. data/bundler/lib/bundler/vendor/postit/lib/postit/setup.rb +0 -12
  346. data/bundler/lib/bundler/vendor/postit/lib/postit/version.rb +0 -3
  347. data/bundler/man/index.txt +0 -8
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "shellwords"
3
4
  require "tempfile"
4
5
  module Bundler
5
6
  class Source
6
- class Git < Path
7
+ class Git
7
8
  class GitNotInstalledError < GitError
8
9
  def initialize
9
10
  msg = String.new
@@ -62,7 +63,7 @@ module Bundler
62
63
  begin
63
64
  @revision ||= find_local_revision
64
65
  rescue GitCommandError
65
- raise MissingGitRevisionError.new(ref, uri)
66
+ raise MissingGitRevisionError.new(ref, URICredentialsFilter.credential_filtered_uri(uri))
66
67
  end
67
68
 
68
69
  @revision
@@ -90,18 +91,21 @@ module Bundler
90
91
  end
91
92
 
92
93
  def checkout
93
- if path.exist?
94
- return if has_revision_cached?
95
- Bundler.ui.info "Fetching #{URICredentialsFilter.credential_filtered_uri(uri)}"
96
- in_path do
97
- git_retry %(fetch --force --quiet --tags #{uri_escaped_with_configured_credentials} "refs/heads/*:refs/heads/*")
98
- end
99
- else
100
- Bundler.ui.info "Fetching #{URICredentialsFilter.credential_filtered_uri(uri)}"
94
+ return if path.exist? && has_revision_cached?
95
+ extra_ref = "#{Shellwords.shellescape(ref)}:#{Shellwords.shellescape(ref)}" if ref && ref.start_with?("refs/")
96
+
97
+ Bundler.ui.info "Fetching #{URICredentialsFilter.credential_filtered_uri(uri)}"
98
+
99
+ unless path.exist?
101
100
  SharedHelpers.filesystem_access(path.dirname) do |p|
102
101
  FileUtils.mkdir_p(p)
103
102
  end
104
103
  git_retry %(clone #{uri_escaped_with_configured_credentials} "#{path}" --bare --no-hardlinks --quiet)
104
+ return unless extra_ref
105
+ end
106
+
107
+ in_path do
108
+ git_retry %(fetch --force --quiet --tags #{uri_escaped_with_configured_credentials} "refs/heads/*:refs/heads/*" #{extra_ref})
105
109
  end
106
110
  end
107
111
 
@@ -132,7 +136,7 @@ module Bundler
132
136
  if submodules
133
137
  git_retry "submodule update --init --recursive"
134
138
  elsif Gem::Version.create(version) >= Gem::Version.create("2.9.0")
135
- git_retry "submodule deinit --all"
139
+ git_retry "submodule deinit --all --force"
136
140
  end
137
141
  end
138
142
  end
@@ -149,7 +153,7 @@ module Bundler
149
153
  end
150
154
 
151
155
  def git_retry(command)
152
- Bundler::Retry.new("`git #{command}`", GitNotAllowedError).attempts do
156
+ Bundler::Retry.new("`git #{URICredentialsFilter.credential_filtered_string(command, uri)}`", GitNotAllowedError).attempts do
153
157
  git(command)
154
158
  end
155
159
  end
@@ -217,6 +221,7 @@ module Bundler
217
221
 
218
222
  def in_path(&blk)
219
223
  checkout unless path.exist?
224
+ _ = URICredentialsFilter # load it before we chdir
220
225
  SharedHelpers.chdir(path, &blk)
221
226
  end
222
227
 
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ class Source
5
+ class Metadata < Source
6
+ def specs
7
+ @specs ||= Index.build do |idx|
8
+ idx << Gem::Specification.new("ruby\0", RubyVersion.system.to_gem_version_with_patchlevel)
9
+ idx << Gem::Specification.new("rubygems\0", Gem::VERSION)
10
+
11
+ idx << Gem::Specification.new do |s|
12
+ s.name = "bundler"
13
+ s.version = VERSION
14
+ s.platform = Gem::Platform::RUBY
15
+ s.source = self
16
+ s.authors = ["bundler team"]
17
+ s.bindir = "exe"
18
+ s.executables = %w[bundle]
19
+ # can't point to the actual gemspec or else the require paths will be wrong
20
+ s.loaded_from = File.expand_path("..", __FILE__)
21
+ end
22
+ if loaded_spec = nil && Bundler.rubygems.loaded_specs("bundler")
23
+ idx << loaded_spec # this has to come after the fake gemspec, to override it
24
+ elsif local_spec = Bundler.rubygems.find_name("bundler").find {|s| s.version.to_s == VERSION }
25
+ idx << local_spec
26
+ end
27
+
28
+ idx.each {|s| s.source = self }
29
+ end
30
+ end
31
+
32
+ def cached!; end
33
+
34
+ def remote!; end
35
+
36
+ def options
37
+ {}
38
+ end
39
+
40
+ def install(spec, _opts = {})
41
+ print_using_message "Using #{version_message(spec)}"
42
+ nil
43
+ end
44
+
45
+ def to_s
46
+ "the local ruby installation"
47
+ end
48
+
49
+ def ==(other)
50
+ self.class == other.class
51
+ end
52
+ alias_method :eql?, :==
53
+
54
+ def hash
55
+ self.class.hash
56
+ end
57
+
58
+ def version_message(spec)
59
+ "#{spec.name} #{spec.version}"
60
+ end
61
+ end
62
+ end
63
+ end
@@ -1,13 +1,16 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Bundler
3
4
  class Source
4
5
  class Path < Source
5
6
  autoload :Installer, "bundler/source/path/installer"
6
7
 
7
- attr_reader :path, :options, :root_path
8
+ attr_reader :path, :options, :root_path, :original_path
8
9
  attr_writer :name
9
10
  attr_accessor :version
10
11
 
12
+ protected :original_path
13
+
11
14
  DEFAULT_GLOB = "{,*,*/*}.gemspec".freeze
12
15
 
13
16
  def initialize(options)
@@ -33,10 +36,12 @@ module Bundler
33
36
  end
34
37
 
35
38
  def remote!
39
+ @local_specs = nil
36
40
  @allow_remote = true
37
41
  end
38
42
 
39
43
  def cached!
44
+ @local_specs = nil
40
45
  @allow_cached = true
41
46
  end
42
47
 
@@ -61,7 +66,7 @@ module Bundler
61
66
 
62
67
  def eql?(other)
63
68
  return unless other.class == self.class
64
- expanded_path == expand(other.path) &&
69
+ expanded_original_path == other.expanded_original_path &&
65
70
  version == other.version
66
71
  end
67
72
 
@@ -71,15 +76,15 @@ module Bundler
71
76
  File.basename(expanded_path.to_s)
72
77
  end
73
78
 
74
- def install(spec, force = false)
75
- Bundler.ui.info "Using #{version_message(spec)} from #{self}"
76
- generate_bin(spec, :disable_extensions)
79
+ def install(spec, options = {})
80
+ print_using_message "Using #{version_message(spec)} from #{self}"
81
+ generate_bin(spec, :disable_extensions => true)
77
82
  nil # no post-install message
78
83
  end
79
84
 
80
85
  def cache(spec, custom_path = nil)
81
86
  app_cache_path = app_cache_path(custom_path)
82
- return unless Bundler.settings[:cache_all]
87
+ return unless Bundler.feature_flag.cache_all?
83
88
  return if expand(@original_path).to_s.index(root_path.to_s + "/") == 0
84
89
 
85
90
  unless @original_path.exist?
@@ -111,8 +116,8 @@ module Bundler
111
116
  Bundler.root
112
117
  end
113
118
 
114
- def is_a_path?
115
- instance_of?(Path)
119
+ def expanded_original_path
120
+ @expanded_original_path ||= expand(original_path)
116
121
  end
117
122
 
118
123
  private
@@ -130,8 +135,8 @@ module Bundler
130
135
  end
131
136
 
132
137
  def lockfile_path
133
- return relative_path if path.absolute?
134
- expand(path).relative_path_from(Bundler.root)
138
+ return relative_path(original_path) if original_path.absolute?
139
+ expand(original_path).relative_path_from(Bundler.root)
135
140
  end
136
141
 
137
142
  def app_cache_path(custom_path = nil)
@@ -142,18 +147,28 @@ module Bundler
142
147
  SharedHelpers.in_bundle? && app_cache_path.exist?
143
148
  end
144
149
 
150
+ def load_gemspec(file)
151
+ return unless spec = Bundler.load_gemspec(file)
152
+ Bundler.rubygems.set_installed_by_version(spec)
153
+ spec
154
+ end
155
+
156
+ def validate_spec(spec)
157
+ Bundler.rubygems.validate(spec)
158
+ end
159
+
145
160
  def load_spec_files
146
161
  index = Index.new
147
162
 
148
163
  if File.directory?(expanded_path)
149
164
  # We sort depth-first since `<<` will override the earlier-found specs
150
165
  Dir["#{expanded_path}/#{@glob}"].sort_by {|p| -p.split(File::SEPARATOR).size }.each do |file|
151
- next unless spec = Bundler.load_gemspec(file)
166
+ next unless spec = load_gemspec(file)
152
167
  spec.source = self
153
- Bundler.rubygems.set_installed_by_version(spec)
168
+
154
169
  # Validation causes extension_dir to be calculated, which depends
155
170
  # on #source, so we validate here instead of load_gemspec
156
- Bundler.rubygems.validate(spec)
171
+ validate_spec(spec)
157
172
  index << spec
158
173
  end
159
174
 
@@ -186,14 +201,14 @@ module Bundler
186
201
  index
187
202
  end
188
203
 
189
- def relative_path
204
+ def relative_path(path = self.path)
190
205
  if path.to_s.start_with?(root_path.to_s)
191
206
  return path.relative_path_from(root_path)
192
207
  end
193
208
  path
194
209
  end
195
210
 
196
- def generate_bin(spec, disable_extensions = false)
211
+ def generate_bin(spec, options = {})
197
212
  gem_dir = Pathname.new(spec.full_gem_path)
198
213
 
199
214
  # Some gem authors put absolute paths in their gemspec
@@ -208,7 +223,13 @@ module Bundler
208
223
  end
209
224
  end.compact
210
225
 
211
- installer = Path::Installer.new(spec, :env_shebang => false, :disable_extensions => disable_extensions)
226
+ installer = Path::Installer.new(
227
+ spec,
228
+ :env_shebang => false,
229
+ :disable_extensions => options[:disable_extensions],
230
+ :build_args => options[:build_args],
231
+ :bundler_extension_cache_path => extension_cache_path(spec)
232
+ )
212
233
  installer.post_install
213
234
  rescue Gem::InvalidSpecificationException => e
214
235
  Bundler.ui.warn "\n#{spec.name} at #{spec.full_gem_path} did not have a valid gemspec.\n" \
@@ -221,7 +242,7 @@ module Bundler
221
242
  "to modify their .gemspec so it can work with `gem build`."
222
243
  end
223
244
 
224
- Bundler.ui.warn "The validation message from Rubygems was:\n #{e.message}"
245
+ Bundler.ui.warn "The validation message from RubyGems was:\n #{e.message}"
225
246
  end
226
247
  end
227
248
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Bundler
3
4
  class Source
4
5
  class Path
@@ -6,6 +7,7 @@ module Bundler
6
7
  attr_reader :spec
7
8
 
8
9
  def initialize(spec, options = {})
10
+ @options = options
9
11
  @spec = spec
10
12
  @gem_dir = Bundler.rubygems.path(spec.full_gem_path)
11
13
  @wrappers = true
@@ -13,7 +15,7 @@ module Bundler
13
15
  @format_executable = options[:format_executable] || false
14
16
  @build_args = options[:build_args] || Bundler.rubygems.build_args
15
17
  @gem_bin_dir = "#{Bundler.rubygems.gem_dir}/bin"
16
- @disable_extentions = options[:disable_extensions]
18
+ @disable_extensions = options[:disable_extensions]
17
19
 
18
20
  if Bundler.requires_sudo?
19
21
  @tmp_dir = Bundler.tmp(spec.full_name).to_s
@@ -27,7 +29,7 @@ module Bundler
27
29
  SharedHelpers.chdir(@gem_dir) do
28
30
  run_hooks(:pre_install)
29
31
 
30
- unless @disable_extentions
32
+ unless @disable_extensions
31
33
  build_extensions
32
34
  run_hooks(:post_build)
33
35
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "uri"
3
4
  require "rubygems/user_interaction"
4
- require "rubygems/spec_fetcher"
5
5
 
6
6
  module Bundler
7
7
  class Source
@@ -32,6 +32,7 @@ module Bundler
32
32
  end
33
33
 
34
34
  def cached!
35
+ @specs = nil
35
36
  @allow_cached = true
36
37
  end
37
38
 
@@ -50,6 +51,7 @@ module Bundler
50
51
  end
51
52
 
52
53
  def can_lock?(spec)
54
+ return super if Bundler.feature_flag.lockfile_uses_separate_rubygems_sources?
53
55
  spec.source.is_a?(Rubygems)
54
56
  end
55
57
 
@@ -70,8 +72,12 @@ module Bundler
70
72
  end
71
73
 
72
74
  def to_s
73
- remote_names = remotes.map(&:to_s).join(", ")
74
- "rubygems repository #{remote_names}"
75
+ if remotes.empty?
76
+ "locally installed gems"
77
+ else
78
+ remote_names = remotes.map(&:to_s).join(", ")
79
+ "rubygems repository #{remote_names} or installed locally"
80
+ end
75
81
  end
76
82
  alias_method :name, :to_s
77
83
 
@@ -100,8 +106,8 @@ module Bundler
100
106
  end
101
107
  end
102
108
 
103
- if installed?(spec) && (!force || spec.name.eql?("bundler"))
104
- Bundler.ui.info "Using #{version_message(spec)}"
109
+ if installed?(spec) && !force
110
+ print_using_message "Using #{version_message(spec)}"
105
111
  return nil # no post-install message
106
112
  end
107
113
 
@@ -142,7 +148,8 @@ module Bundler
142
148
  :wrappers => true,
143
149
  :env_shebang => true,
144
150
  :build_args => opts[:build_args],
145
- :bundler_expected_checksum => spec.respond_to?(:checksum) && spec.checksum
151
+ :bundler_expected_checksum => spec.respond_to?(:checksum) && spec.checksum,
152
+ :bundler_extension_cache_path => extension_cache_path(spec)
146
153
  ).install
147
154
  end
148
155
  spec.full_gem_path = installed_spec.full_gem_path
@@ -213,13 +220,21 @@ module Bundler
213
220
  @remotes.unshift(uri) unless @remotes.include?(uri)
214
221
  end
215
222
 
216
- def replace_remotes(other_remotes)
223
+ def equivalent_remotes?(other_remotes)
224
+ other_remotes.map(&method(:remove_auth)) == @remotes.map(&method(:remove_auth))
225
+ end
226
+
227
+ def replace_remotes(other_remotes, allow_equivalent = false)
217
228
  return false if other_remotes == @remotes
218
229
 
230
+ equivalent = allow_equivalent && equivalent_remotes?(other_remotes)
231
+
219
232
  @remotes = []
220
233
  other_remotes.reverse_each do |r|
221
234
  add_remote r.to_s
222
235
  end
236
+
237
+ !equivalent
223
238
  end
224
239
 
225
240
  def unmet_deps
@@ -237,6 +252,43 @@ module Bundler
237
252
  end
238
253
  end
239
254
 
255
+ def double_check_for(unmet_dependency_names, override_dupes = false, index = specs)
256
+ return unless @allow_remote
257
+ raise ArgumentError, "missing index" unless index
258
+
259
+ return unless api_fetchers.any?
260
+
261
+ unmet_dependency_names = unmet_dependency_names.call
262
+ unless unmet_dependency_names.nil?
263
+ if api_fetchers.size <= 1
264
+ # can't do this when there are multiple fetchers because then we might not fetch from _all_
265
+ # of them
266
+ unmet_dependency_names -= remote_specs.spec_names # avoid re-fetching things we've already gotten
267
+ end
268
+ return if unmet_dependency_names.empty?
269
+ end
270
+
271
+ Bundler.ui.debug "Double checking for #{unmet_dependency_names || "all specs (due to the size of the request)"} in #{self}"
272
+
273
+ fetch_names(api_fetchers, unmet_dependency_names, index, override_dupes)
274
+ end
275
+
276
+ def dependency_names_to_double_check
277
+ names = []
278
+ remote_specs.each do |spec|
279
+ case spec
280
+ when EndpointSpecification, Gem::Specification, StubSpecification, LazySpecification
281
+ names.concat(spec.runtime_dependencies)
282
+ when RemoteSpecification # from the full index
283
+ return nil
284
+ else
285
+ raise "unhandled spec type (#{spec.inspect})"
286
+ end
287
+ end
288
+ names.map!(&:name) if names
289
+ names
290
+ end
291
+
240
292
  protected
241
293
 
242
294
  def credless_remotes
@@ -277,7 +329,7 @@ module Bundler
277
329
  end
278
330
 
279
331
  def suppress_configured_credentials(remote)
280
- remote_nouser = remote.dup.tap {|uri| uri.user = uri.password = nil }.to_s
332
+ remote_nouser = remove_auth(remote)
281
333
  if remote.userinfo && remote.userinfo == Bundler.settings[remote_nouser]
282
334
  remote_nouser
283
335
  else
@@ -285,13 +337,14 @@ module Bundler
285
337
  end
286
338
  end
287
339
 
340
+ def remove_auth(remote)
341
+ remote.dup.tap {|uri| uri.user = uri.password = nil }.to_s
342
+ end
343
+
288
344
  def installed_specs
289
- @installed_specs ||= begin
290
- idx = Index.new
291
- have_bundler = false
345
+ @installed_specs ||= Index.build do |idx|
292
346
  Bundler.rubygems.all_specs.reverse_each do |spec|
293
- next if spec.name == "bundler" && spec.version.to_s != VERSION
294
- have_bundler = true if spec.name == "bundler"
347
+ next if spec.name == "bundler"
295
348
  spec.source = self
296
349
  if Bundler.rubygems.spec_missing_extensions?(spec, false)
297
350
  Bundler.ui.debug "Source #{self} is ignoring #{spec} because it is missing extensions"
@@ -299,23 +352,6 @@ module Bundler
299
352
  end
300
353
  idx << spec
301
354
  end
302
-
303
- # Always have bundler locally
304
- unless have_bundler
305
- # We're running bundler directly from the source
306
- # so, let's create a fake gemspec for it (it's a path)
307
- # gemspec
308
- bundler = Gem::Specification.new do |s|
309
- s.name = "bundler"
310
- s.version = VERSION
311
- s.platform = Gem::Platform::RUBY
312
- s.source = self
313
- s.authors = ["bundler team"]
314
- s.loaded_from = File.expand_path("..", __FILE__)
315
- end
316
- idx << bundler
317
- end
318
- idx
319
355
  end
320
356
  end
321
357
 
@@ -333,9 +369,9 @@ module Bundler
333
369
  end
334
370
  idx << s
335
371
  end
336
- end
337
372
 
338
- idx
373
+ idx
374
+ end
339
375
  end
340
376
 
341
377
  def api_fetchers
@@ -347,69 +383,35 @@ module Bundler
347
383
  index_fetchers = fetchers - api_fetchers
348
384
 
349
385
  # gather lists from non-api sites
350
- index_fetchers.each do |f|
351
- Bundler.ui.info "Fetching source index from #{f.uri}"
352
- idx.use f.specs_with_retry(nil, self)
353
- end
386
+ fetch_names(index_fetchers, nil, idx, false)
354
387
 
355
388
  # because ensuring we have all the gems we need involves downloading
356
389
  # the gemspecs of those gems, if the non-api sites contain more than
357
- # about 100 gems, we treat all sites as non-api for speed.
390
+ # about 500 gems, we treat all sites as non-api for speed.
358
391
  allow_api = idx.size < API_REQUEST_LIMIT && dependency_names.size < API_REQUEST_LIMIT
359
392
  Bundler.ui.debug "Need to query more than #{API_REQUEST_LIMIT} gems." \
360
393
  " Downloading full index instead..." unless allow_api
361
394
 
362
- if allow_api
363
- api_fetchers.each do |f|
364
- Bundler.ui.info "Fetching gem metadata from #{f.uri}", Bundler.ui.debug?
365
- idx.use f.specs_with_retry(dependency_names, self)
366
- Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
367
- end
368
-
369
- # Suppose the gem Foo depends on the gem Bar. Foo exists in Source A. Bar has some versions that exist in both
370
- # sources A and B. At this point, the API request will have found all the versions of Bar in source A,
371
- # but will not have found any versions of Bar from source B, which is a problem if the requested version
372
- # of Foo specifically depends on a version of Bar that is only found in source B. This ensures that for
373
- # each spec we found, we add all possible versions from all sources to the index.
374
- loop do
375
- idxcount = idx.size
376
- api_fetchers.each do |f|
377
- Bundler.ui.info "Fetching version metadata from #{f.uri}", Bundler.ui.debug?
378
- idx.use f.specs_with_retry(idx.dependency_names, self), true
379
- Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
380
- end
381
- break if idxcount == idx.size
382
- end
383
-
384
- if api_fetchers.any?
385
- # it's possible that gems from one source depend on gems from some
386
- # other source, so now we download gemspecs and iterate over those
387
- # dependencies, looking for gems we don't have info on yet.
388
- unmet = idx.unmet_dependency_names
389
-
390
- # if there are any cross-site gems we missed, get them now
391
- api_fetchers.each do |f|
392
- Bundler.ui.info "Fetching dependency metadata from #{f.uri}", Bundler.ui.debug?
393
- idx.use f.specs_with_retry(unmet, self)
394
- Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
395
- end if unmet.any?
396
- else
397
- allow_api = false
398
- end
399
- end
395
+ fetch_names(api_fetchers, allow_api && dependency_names, idx, false)
396
+ end
397
+ end
400
398
 
401
- unless allow_api
402
- api_fetchers.each do |f|
403
- Bundler.ui.info "Fetching source index from #{f.uri}"
404
- idx.use f.specs_with_retry(nil, self)
405
- end
399
+ def fetch_names(fetchers, dependency_names, index, override_dupes)
400
+ fetchers.each do |f|
401
+ if dependency_names
402
+ Bundler.ui.info "Fetching gem metadata from #{f.uri}", Bundler.ui.debug?
403
+ index.use f.specs_with_retry(dependency_names, self), override_dupes
404
+ Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
405
+ else
406
+ Bundler.ui.info "Fetching source index from #{f.uri}"
407
+ index.use f.specs_with_retry(nil, self), override_dupes
406
408
  end
407
409
  end
408
410
  end
409
411
 
410
412
  def fetch_gem(spec)
411
413
  return false unless spec.remote
412
- uri = spec.remote.uri
414
+
413
415
  spec.fetch_platform
414
416
 
415
417
  download_path = requires_sudo? ? Bundler.tmp(spec.full_name) : rubygems_dir
@@ -418,7 +420,7 @@ module Bundler
418
420
  SharedHelpers.filesystem_access("#{download_path}/cache") do |p|
419
421
  FileUtils.mkdir_p(p)
420
422
  end
421
- Bundler.rubygems.download_gem(spec, uri, download_path)
423
+ download_gem(spec, download_path)
422
424
 
423
425
  if requires_sudo?
424
426
  SharedHelpers.filesystem_access("#{rubygems_dir}/cache") do |p|
@@ -455,6 +457,76 @@ module Bundler
455
457
  def cache_path
456
458
  Bundler.app_cache
457
459
  end
460
+
461
+ private
462
+
463
+ # Checks if the requested spec exists in the global cache. If it does,
464
+ # we copy it to the download path, and if it does not, we download it.
465
+ #
466
+ # @param [Specification] spec
467
+ # the spec we want to download or retrieve from the cache.
468
+ #
469
+ # @param [String] download_path
470
+ # the local directory the .gem will end up in.
471
+ #
472
+ def download_gem(spec, download_path)
473
+ local_path = File.join(download_path, "cache/#{spec.full_name}.gem")
474
+
475
+ if (cache_path = download_cache_path(spec)) && cache_path.file?
476
+ SharedHelpers.filesystem_access(local_path) do
477
+ FileUtils.cp(cache_path, local_path)
478
+ end
479
+ else
480
+ uri = spec.remote.uri
481
+ Bundler.ui.confirm("Fetching #{version_message(spec)}")
482
+ Bundler.rubygems.download_gem(spec, uri, download_path)
483
+ cache_globally(spec, local_path)
484
+ end
485
+ end
486
+
487
+ # Checks if the requested spec exists in the global cache. If it does
488
+ # not, we create the relevant global cache subdirectory if it does not
489
+ # exist and copy the spec from the local cache to the global cache.
490
+ #
491
+ # @param [Specification] spec
492
+ # the spec we want to copy to the global cache.
493
+ #
494
+ # @param [String] local_cache_path
495
+ # the local directory from which we want to copy the .gem.
496
+ #
497
+ def cache_globally(spec, local_cache_path)
498
+ return unless cache_path = download_cache_path(spec)
499
+ return if cache_path.exist?
500
+
501
+ SharedHelpers.filesystem_access(cache_path.dirname, &:mkpath)
502
+ SharedHelpers.filesystem_access(cache_path) do
503
+ FileUtils.cp(local_cache_path, cache_path)
504
+ end
505
+ end
506
+
507
+ # Returns the global cache path of the calling Rubygems::Source object.
508
+ #
509
+ # Note that the Source determines the path's subdirectory. We use this
510
+ # subdirectory in the global cache path so that gems with the same name
511
+ # -- and possibly different versions -- from different sources are saved
512
+ # to their respective subdirectories and do not override one another.
513
+ #
514
+ # @param [Gem::Specification] specification
515
+ #
516
+ # @return [Pathname] The global cache path.
517
+ #
518
+ def download_cache_path(spec)
519
+ return unless Bundler.feature_flag.global_gem_cache?
520
+ return unless remote = spec.remote
521
+ return unless cache_slug = remote.cache_slug
522
+
523
+ Bundler.user_cache.join("gems", cache_slug, spec.file_name)
524
+ end
525
+
526
+ def extension_cache_slug(spec)
527
+ return unless remote = spec.remote
528
+ remote.cache_slug
529
+ end
458
530
  end
459
531
  end
460
532
  end