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,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Bundler
3
4
  class CLI::Package
4
5
  attr_reader :options
@@ -9,15 +10,15 @@ module Bundler
9
10
 
10
11
  def run
11
12
  Bundler.ui.level = "error" if options[:quiet]
12
- Bundler.settings[:path] = File.expand_path(options[:path]) if options[:path]
13
- Bundler.settings[:cache_all_platforms] = options["all-platforms"] if options.key?("all-platforms")
14
- Bundler.settings[:cache_path] = options["cache-path"] if options.key?("cache-path")
13
+ Bundler.settings.set_command_option_if_given :path, options[:path]
14
+ Bundler.settings.set_command_option_if_given :cache_all_platforms, options["all-platforms"]
15
+ Bundler.settings.set_command_option_if_given :cache_path, options["cache-path"]
15
16
 
16
17
  setup_cache_all
17
18
  install
18
19
 
19
20
  # TODO: move cache contents here now that all bundles are locked
20
- custom_path = Pathname.new(options[:path]) if options[:path]
21
+ custom_path = Bundler.settings[:path] if options[:path]
21
22
  Bundler.load.cache(custom_path)
22
23
  end
23
24
 
@@ -34,9 +35,11 @@ module Bundler
34
35
  end
35
36
 
36
37
  def setup_cache_all
37
- Bundler.settings[:cache_all] = options[:all] if options.key?("all")
38
+ all = options.fetch(:all, Bundler.feature_flag.cache_command_is_package? || nil)
39
+
40
+ Bundler.settings.set_command_option_if_given :cache_all, all
38
41
 
39
- if Bundler.definition.has_local_dependencies? && !Bundler.settings[:cache_all]
42
+ if Bundler.definition.has_local_dependencies? && !Bundler.feature_flag.cache_all?
40
43
  Bundler.ui.warn "Your Gemfile contains path and git dependencies. If you want " \
41
44
  "to package them as well, please pass the --all flag. This will be the default " \
42
45
  "on Bundler 2.0."
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Bundler
3
4
  class CLI::Platform
4
5
  attr_reader :options
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "bundler/vendored_thor"
3
4
  module Bundler
4
5
  class CLI::Plugin < Thor
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ class CLI::Pristine
5
+ def initialize(gems)
6
+ @gems = gems
7
+ end
8
+
9
+ def run
10
+ CLI::Common.ensure_all_gems_in_lockfile!(@gems)
11
+ definition = Bundler.definition
12
+ definition.validate_runtime!
13
+ installer = Bundler::Installer.new(Bundler.root, definition)
14
+
15
+ Bundler.load.specs.each do |spec|
16
+ next if spec.name == "bundler" # Source::Rubygems doesn't install bundler
17
+ next if !@gems.empty? && !@gems.include?(spec.name)
18
+
19
+ gem_name = "#{spec.name} (#{spec.version}#{spec.git_version})"
20
+ gem_name += " (#{spec.platform})" if !spec.platform.nil? && spec.platform != Gem::Platform::RUBY
21
+
22
+ case source = spec.source
23
+ when Source::Rubygems
24
+ cached_gem = spec.cache_file
25
+ unless File.exist?(cached_gem)
26
+ Bundler.ui.error("Failed to pristine #{gem_name}. Cached gem #{cached_gem} does not exist.")
27
+ next
28
+ end
29
+
30
+ FileUtils.rm_rf spec.full_gem_path
31
+ when Source::Git
32
+ source.remote!
33
+ FileUtils.rm_rf spec.full_gem_path
34
+ else
35
+ Bundler.ui.warn("Cannot pristine #{gem_name}. Gem is sourced from local path.")
36
+ next
37
+ end
38
+
39
+ Bundler::GemInstaller.new(spec, installer, false, 0, true).install_from_spec
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- require "bundler/cli/common"
3
2
 
4
3
  module Bundler
5
4
  class CLI::Show
@@ -64,6 +63,7 @@ module Bundler
64
63
  else
65
64
  definition.resolve_with_cache!
66
65
  end
66
+ Bundler.reset!
67
67
  definition.specs
68
68
  end
69
69
 
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- require "bundler/cli/common"
3
2
 
4
3
  module Bundler
5
4
  class CLI::Update
@@ -17,7 +16,18 @@ module Bundler
17
16
  sources = Array(options[:source])
18
17
  groups = Array(options[:group]).map(&:to_sym)
19
18
 
20
- if gems.empty? && sources.empty? && groups.empty? && !options[:ruby] && !options[:bundler]
19
+ full_update = gems.empty? && sources.empty? && groups.empty? && !options[:ruby] && !options[:bundler]
20
+
21
+ if full_update && !options[:all]
22
+ if Bundler.feature_flag.update_requires_all_flag?
23
+ raise InvalidOption, "To update everything, pass the `--all` flag."
24
+ end
25
+ SharedHelpers.major_deprecation 2, "Pass --all to `bundle update` to update everything"
26
+ elsif !full_update && options[:all]
27
+ raise InvalidOption, "Cannot specify --all along with specific options."
28
+ end
29
+
30
+ if full_update
21
31
  # We're doing a full update
22
32
  Bundler.definition(true)
23
33
  else
@@ -25,12 +35,7 @@ module Bundler
25
35
  raise GemfileLockNotFound, "This Bundle hasn't been installed yet. " \
26
36
  "Run `bundle install` to update and install the bundled gems."
27
37
  end
28
- # cycle through the requested gems, to make sure they exist
29
- names = Bundler.locked_gems.specs.map(&:name)
30
- gems.each do |g|
31
- next if names.include?(g)
32
- raise GemNotFound, Bundler::CLI::Common.gem_not_found_message(g, names)
33
- end
38
+ Bundler::CLI::Common.ensure_all_gems_in_lockfile!(gems)
34
39
 
35
40
  if groups.any?
36
41
  specs = Bundler.definition.specs_for groups
@@ -38,7 +43,8 @@ module Bundler
38
43
  end
39
44
 
40
45
  Bundler.definition(:gems => gems, :sources => sources, :ruby => options[:ruby],
41
- :lock_shared_dependencies => options[:conservative])
46
+ :lock_shared_dependencies => options[:conservative],
47
+ :bundler => options[:bundler])
42
48
  end
43
49
 
44
50
  Bundler::CLI::Common.configure_gem_version_promoter(Bundler.definition, options)
@@ -49,17 +55,32 @@ module Bundler
49
55
  opts["update"] = true
50
56
  opts["local"] = options[:local]
51
57
 
52
- Bundler.settings[:jobs] = opts["jobs"] if opts["jobs"]
58
+ Bundler.settings.set_command_option_if_given :jobs, opts["jobs"]
53
59
 
54
60
  Bundler.definition.validate_runtime!
55
61
  installer = Installer.install Bundler.root, Bundler.definition, opts
56
62
  Bundler.load.cache if Bundler.app_cache.exist?
57
63
 
58
- if Bundler.settings[:clean] && Bundler.settings[:path]
64
+ if CLI::Common.clean_after_install?
59
65
  require "bundler/cli/clean"
60
66
  Bundler::CLI::Clean.new(options).run
61
67
  end
62
68
 
69
+ if locked_gems = Bundler.definition.locked_gems
70
+ gems.each do |name|
71
+ locked_version = locked_gems.specs.find {|s| s.name == name }.version
72
+ new_version = Bundler.definition.specs[name].first
73
+ new_version &&= new_version.version
74
+ if !new_version
75
+ Bundler.ui.warn "Bundler attempted to update #{name} but it was removed from the bundle"
76
+ elsif new_version < locked_version
77
+ Bundler.ui.warn "Bundler attempted to update #{name} but its version regressed from #{locked_version} to #{new_version}"
78
+ elsif new_version == locked_version
79
+ Bundler.ui.warn "Bundler attempted to update #{name} but its version stayed the same"
80
+ end
81
+ end
82
+ end
83
+
63
84
  Bundler.ui.confirm "Bundle updated!"
64
85
  Bundler::CLI::Common.output_without_groups_message
65
86
  Bundler::CLI::Common.output_post_install_messages installer.post_install_messages
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Bundler
3
4
  class CLI::Viz
4
5
  attr_reader :options, :gem_name
@@ -7,6 +8,9 @@ module Bundler
7
8
  end
8
9
 
9
10
  def run
11
+ # make sure we get the right `graphviz`. There is also a `graphviz`
12
+ # gem we're not built to support
13
+ gem "ruby-graphviz"
10
14
  require "graphviz"
11
15
 
12
16
  options[:without] = options[:without].join(":").tr(" ", ":").split(":")
@@ -21,7 +25,7 @@ module Bundler
21
25
  rescue StandardError => e
22
26
  raise unless e.message =~ /GraphViz not installed or dot not in PATH/
23
27
  Bundler.ui.error e.message
24
- Bundler.ui.warn "Please install GraphViz. On a Mac with homebrew, you can run `brew install graphviz`."
28
+ Bundler.ui.warn "Please install GraphViz. On a Mac with Homebrew, you can run `brew install graphviz`."
25
29
  end
26
30
  end
27
31
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "pathname"
3
4
  require "set"
4
5
 
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- require "digest/md5"
3
2
 
4
3
  module Bundler
5
4
  class CompactIndexClient
@@ -68,7 +67,7 @@ module Bundler
68
67
  def info_path(name)
69
68
  name = name.to_s
70
69
  if name =~ /[^a-z0-9_-]/
71
- name += "-#{Digest::MD5.hexdigest(name).downcase}"
70
+ name += "-#{SharedHelpers.digest(:MD5).hexdigest(name).downcase}"
72
71
  info_roots.last.join(name)
73
72
  else
74
73
  info_roots.first.join(name)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
- require "fileutils"
2
+
3
+ require "bundler/vendored_fileutils"
3
4
  require "stringio"
4
- require "tmpdir"
5
5
  require "zlib"
6
6
 
7
7
  module Bundler
@@ -22,6 +22,7 @@ module Bundler
22
22
 
23
23
  def initialize(fetcher)
24
24
  @fetcher = fetcher
25
+ require "tmpdir"
25
26
  end
26
27
 
27
28
  def update(local_path, remote_path, retrying = nil)
@@ -34,7 +35,14 @@ module Bundler
34
35
  if retrying.nil? && local_path.file?
35
36
  FileUtils.cp local_path, local_temp_path
36
37
  headers["If-None-Match"] = etag_for(local_temp_path)
37
- headers["Range"] = "bytes=#{local_temp_path.size}-"
38
+ headers["Range"] =
39
+ if local_temp_path.size.nonzero?
40
+ # Subtract a byte to ensure the range won't be empty.
41
+ # Avoids 416 (Range Not Satisfiable) responses.
42
+ "bytes=#{local_temp_path.size - 1}-"
43
+ else
44
+ "bytes=#{local_temp_path.size}-"
45
+ end
38
46
  else
39
47
  # Fastly ignores Range when Accept-Encoding: gzip is set
40
48
  headers["Accept-Encoding"] = "gzip"
@@ -48,12 +56,15 @@ module Bundler
48
56
  content = Zlib::GzipReader.new(StringIO.new(content)).read
49
57
  end
50
58
 
51
- mode = response.is_a?(Net::HTTPPartialContent) ? "a" : "w"
52
59
  SharedHelpers.filesystem_access(local_temp_path) do
53
- local_temp_path.open(mode) {|f| f << content }
60
+ if response.is_a?(Net::HTTPPartialContent) && local_temp_path.size.nonzero?
61
+ local_temp_path.open("a") {|f| f << slice_body(content, 1..-1) }
62
+ else
63
+ local_temp_path.open("w") {|f| f << content }
64
+ end
54
65
  end
55
66
 
56
- response_etag = response["ETag"].gsub(%r{\AW/}, "")
67
+ response_etag = (response["ETag"] || "").gsub(%r{\AW/}, "")
57
68
  if etag_for(local_temp_path) == response_etag
58
69
  SharedHelpers.filesystem_access(local_path) do
59
70
  FileUtils.mv(local_temp_path, local_path)
@@ -74,13 +85,21 @@ module Bundler
74
85
  sum ? %("#{sum}") : nil
75
86
  end
76
87
 
88
+ def slice_body(body, range)
89
+ if body.respond_to?(:byteslice)
90
+ body.byteslice(range)
91
+ else # pre-1.9.3
92
+ body.unpack("@#{range.first}a#{range.end + 1}").first
93
+ end
94
+ end
95
+
77
96
  def checksum_for_file(path)
78
97
  return nil unless path.file?
79
98
  # This must use IO.read instead of Digest.file().hexdigest
80
99
  # because we need to preserve \n line endings on windows when calculating
81
100
  # the checksum
82
101
  SharedHelpers.filesystem_access(path, :read) do
83
- Digest::MD5.hexdigest(IO.read(path))
102
+ SharedHelpers.digest(:MD5).hexdigest(IO.read(path))
84
103
  end
85
104
  end
86
105
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: false
2
+
3
+ require "rubygems"
4
+ require "bundler/version"
5
+
6
+ if Bundler::VERSION.split(".").first.to_i >= 2
7
+ if Gem::Version.new(Object::RUBY_VERSION.dup) < Gem::Version.new("2.3")
8
+ abort "Bundler 2 requires Ruby 2.3 or later. Either install bundler 1 or update to a supported Ruby version."
9
+ end
10
+
11
+ if Gem::Version.new(Gem::VERSION.dup) < Gem::Version.new("2.5")
12
+ abort "Bundler 2 requires RubyGems 2.5 or later. Either install bundler 1 or update to a supported RubyGems version."
13
+ end
14
+ end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Bundler
3
4
  WINDOWS = RbConfig::CONFIG["host_os"] =~ /(msdos|mswin|djgpp|mingw)/
4
5
  FREEBSD = RbConfig::CONFIG["host_os"] =~ /bsd/
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Bundler
3
4
  # Returns current version of Ruby
4
5
  #
@@ -8,7 +9,7 @@ module Bundler
8
9
  end
9
10
 
10
11
  class CurrentRuby
11
- KNOWN_MINOR_VERSIONS = %w(
12
+ KNOWN_MINOR_VERSIONS = %w[
12
13
  1.8
13
14
  1.9
14
15
  2.0
@@ -17,11 +18,11 @@ module Bundler
17
18
  2.3
18
19
  2.4
19
20
  2.5
20
- ).freeze
21
+ ].freeze
21
22
 
22
23
  KNOWN_MAJOR_VERSIONS = KNOWN_MINOR_VERSIONS.map {|v| v.split(".", 2).first }.uniq.freeze
23
24
 
24
- KNOWN_PLATFORMS = %w(
25
+ KNOWN_PLATFORMS = %w[
25
26
  jruby
26
27
  maglev
27
28
  mingw
@@ -31,7 +32,7 @@ module Bundler
31
32
  rbx
32
33
  ruby
33
34
  x64_mingw
34
- ).freeze
35
+ ].freeze
35
36
 
36
37
  def ruby?
37
38
  !mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby" || RUBY_ENGINE == "rbx" || RUBY_ENGINE == "maglev")
@@ -58,15 +59,15 @@ module Bundler
58
59
  end
59
60
 
60
61
  def mswin64?
61
- Bundler::WINDOWS && Bundler.local_platform.os == "mswin64" && Bundler.local_platform.cpu == "x64"
62
+ Bundler::WINDOWS && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mswin64" && Bundler.local_platform.cpu == "x64"
62
63
  end
63
64
 
64
65
  def mingw?
65
- Bundler::WINDOWS && Bundler.local_platform.os == "mingw32" && Bundler.local_platform.cpu != "x64"
66
+ Bundler::WINDOWS && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mingw32" && Bundler.local_platform.cpu != "x64"
66
67
  end
67
68
 
68
69
  def x64_mingw?
69
- Bundler::WINDOWS && Bundler.local_platform.os == "mingw32" && Bundler.local_platform.cpu == "x64"
70
+ Bundler::WINDOWS && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mingw32" && Bundler.local_platform.cpu == "x64"
70
71
  end
71
72
 
72
73
  (KNOWN_MINOR_VERSIONS + KNOWN_MAJOR_VERSIONS).each do |version|
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "bundler/lockfile_parser"
3
- require "digest/sha1"
4
4
  require "set"
5
5
 
6
6
  module Bundler
@@ -14,7 +14,9 @@ module Bundler
14
14
  :locked_gems,
15
15
  :platforms,
16
16
  :requires,
17
- :ruby_version
17
+ :ruby_version,
18
+ :lockfile,
19
+ :gemfiles
18
20
  )
19
21
 
20
22
  # Given a gemfile and lockfile creates a Bundler definition
@@ -51,8 +53,16 @@ module Bundler
51
53
  # to be updated or true if all gems should be updated
52
54
  # @param ruby_version [Bundler::RubyVersion, nil] Requested Ruby Version
53
55
  # @param optional_groups [Array(String)] A list of optional groups
54
- def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, optional_groups = [])
55
- @unlocking = unlock == true || !unlock.empty?
56
+ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, optional_groups = [], gemfiles = [])
57
+ if [true, false].include?(unlock)
58
+ @unlocking_bundler = false
59
+ @unlocking = unlock
60
+ else
61
+ unlock = unlock.dup
62
+ @unlocking_bundler = unlock.delete(:bundler)
63
+ unlock.delete_if {|_k, v| Array(v).empty? }
64
+ @unlocking = !unlock.empty?
65
+ end
56
66
 
57
67
  @dependencies = dependencies
58
68
  @sources = sources
@@ -61,6 +71,7 @@ module Bundler
61
71
  @remote = false
62
72
  @specs = nil
63
73
  @ruby_version = ruby_version
74
+ @gemfiles = gemfiles
64
75
 
65
76
  @lockfile = lockfile
66
77
  @lockfile_contents = String.new
@@ -81,7 +92,7 @@ module Bundler
81
92
  @locked_sources = @locked_gems.sources
82
93
  else
83
94
  @unlock = {}
84
- @locked_deps = []
95
+ @locked_deps = {}
85
96
  @locked_specs = SpecSet.new([])
86
97
  @locked_sources = []
87
98
  end
@@ -89,7 +100,7 @@ module Bundler
89
100
  @unlock = {}
90
101
  @platforms = []
91
102
  @locked_gems = nil
92
- @locked_deps = []
103
+ @locked_deps = {}
93
104
  @locked_specs = SpecSet.new([])
94
105
  @locked_sources = []
95
106
  @locked_platforms = []
@@ -102,9 +113,11 @@ module Bundler
102
113
  end
103
114
  @unlocking ||= @unlock[:ruby] ||= (!@locked_ruby_version ^ !@ruby_version)
104
115
 
105
- add_current_platform unless Bundler.settings[:frozen]
116
+ add_current_platform unless Bundler.frozen?
106
117
 
118
+ converge_path_sources_to_gemspec_sources
107
119
  @path_changes = converge_paths
120
+ @source_changes = converge_sources
108
121
 
109
122
  unless @unlock[:lock_shared_dependencies]
110
123
  eager_unlock = expand_dependencies(@unlock[:gems])
@@ -113,33 +126,15 @@ module Bundler
113
126
 
114
127
  @gem_version_promoter = create_gem_version_promoter
115
128
 
116
- @source_changes = converge_sources
117
129
  @dependency_changes = converge_dependencies
118
130
  @local_changes = converge_locals
119
131
 
120
132
  @requires = compute_requires
121
-
122
- fixup_dependency_types!
123
- end
124
-
125
- def fixup_dependency_types!
126
- # XXX This is a temporary workaround for a bug when using rubygems 1.8.15
127
- # where Gem::Dependency#== matches Gem::Dependency#type. As the lockfile
128
- # doesn't carry a notion of the dependency type, if you use
129
- # add_development_dependency in a gemspec that's loaded with the gemspec
130
- # directive, the lockfile dependencies and resolved dependencies end up
131
- # with a mismatch on #type.
132
- # Test coverage to catch a regression on this is in gemspec_spec.rb
133
- @dependencies.each do |d|
134
- if ld = @locked_deps.find {|l| l.name == d.name }
135
- ld.instance_variable_set(:@type, d.type)
136
- end
137
- end
138
133
  end
139
134
 
140
135
  def create_gem_version_promoter
141
136
  locked_specs =
142
- if @unlocking && @locked_specs.empty? && !@lockfile_contents.empty?
137
+ if unlocking? && @locked_specs.empty? && !@lockfile_contents.empty?
143
138
  # Definition uses an empty set of locked_specs to indicate all gems
144
139
  # are unlocked, but GemVersionPromoter needs the locked_specs
145
140
  # for conservative comparison.
@@ -183,9 +178,8 @@ module Bundler
183
178
  "to a different version of #{locked_gem} that hasn't been removed in order to install."
184
179
  end
185
180
  unless specs["bundler"].any?
186
- local = Bundler.settings[:frozen] ? rubygems_index : index
187
- bundler = local.search(Gem::Dependency.new("bundler", VERSION)).last
188
- specs["bundler"] = bundler if bundler
181
+ bundler = sources.metadata_source.specs.search(Gem::Dependency.new("bundler", VERSION)).last
182
+ specs["bundler"] = bundler
189
183
  end
190
184
 
191
185
  specs
@@ -210,10 +204,19 @@ module Bundler
210
204
  missing
211
205
  end
212
206
 
213
- def missing_dependencies
214
- missing = []
215
- resolve.materialize(current_dependencies, missing)
216
- missing
207
+ def missing_specs?
208
+ missing = missing_specs
209
+ return false if missing.empty?
210
+ Bundler.ui.debug "The definition is missing #{missing.map(&:full_name)}"
211
+ true
212
+ rescue BundlerError => e
213
+ @index = nil
214
+ @resolve = nil
215
+ @specs = nil
216
+ @gem_version_promoter = create_gem_version_promoter
217
+
218
+ Bundler.ui.debug "The definition is missing dependencies, failed to resolve & materialize locally (#{e})"
219
+ true
217
220
  end
218
221
 
219
222
  def requested_specs
@@ -242,13 +245,16 @@ module Bundler
242
245
  def resolve
243
246
  @resolve ||= begin
244
247
  last_resolve = converge_locked_specs
245
- if Bundler.settings[:frozen] || (!@unlocking && nothing_changed?)
248
+ if Bundler.frozen?
249
+ Bundler.ui.debug "Frozen, using resolution from the lockfile"
250
+ last_resolve
251
+ elsif !unlocking? && nothing_changed?
246
252
  Bundler.ui.debug("Found no changes, using resolution from the lockfile")
247
253
  last_resolve
248
254
  else
249
255
  # Run a resolve against the locally available gems
250
256
  Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}")
251
- last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve)
257
+ last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
252
258
  end
253
259
  end
254
260
  end
@@ -258,25 +264,44 @@ module Bundler
258
264
  dependency_names = @dependencies.map(&:name)
259
265
 
260
266
  sources.all_sources.each do |source|
261
- source.dependency_names = dependency_names.dup
267
+ source.dependency_names = dependency_names - pinned_spec_names(source)
262
268
  idx.add_source source.specs
263
- dependency_names -= pinned_spec_names(source.specs)
264
269
  dependency_names.concat(source.unmet_deps).uniq!
265
270
  end
266
- idx << Gem::Specification.new("ruby\0", RubyVersion.system.to_gem_version_with_patchlevel)
267
- idx << Gem::Specification.new("rubygems\0", Gem::VERSION)
268
- end
269
- end
270
271
 
271
- # used when frozen is enabled so we can find the bundler
272
- # spec, even if (say) a git gem is not checked out.
273
- def rubygems_index
274
- @rubygems_index ||= Index.build do |idx|
275
- sources.rubygems_sources.each do |rubygems|
276
- idx.add_source rubygems.specs
272
+ double_check_for_index(idx, dependency_names)
273
+ end
274
+ end
275
+
276
+ # Suppose the gem Foo depends on the gem Bar. Foo exists in Source A. Bar has some versions that exist in both
277
+ # sources A and B. At this point, the API request will have found all the versions of Bar in source A,
278
+ # but will not have found any versions of Bar from source B, which is a problem if the requested version
279
+ # of Foo specifically depends on a version of Bar that is only found in source B. This ensures that for
280
+ # each spec we found, we add all possible versions from all sources to the index.
281
+ def double_check_for_index(idx, dependency_names)
282
+ pinned_names = pinned_spec_names
283
+ loop do
284
+ idxcount = idx.size
285
+
286
+ names = :names # do this so we only have to traverse to get dependency_names from the index once
287
+ unmet_dependency_names = lambda do
288
+ return names unless names == :names
289
+ new_names = sources.all_sources.map(&:dependency_names_to_double_check)
290
+ return names = nil if new_names.compact!
291
+ names = new_names.flatten(1).concat(dependency_names)
292
+ names.uniq!
293
+ names -= pinned_names
294
+ names
277
295
  end
296
+
297
+ sources.all_sources.each do |source|
298
+ source.double_check_for(unmet_dependency_names, :override_dupes)
299
+ end
300
+
301
+ break if idxcount == idx.size
278
302
  end
279
303
  end
304
+ private :double_check_for_index
280
305
 
281
306
  def has_rubygems_remotes?
282
307
  sources.rubygems_sources.any? {|s| s.remotes.any? }
@@ -311,10 +336,10 @@ module Bundler
311
336
  end
312
337
  end
313
338
 
314
- preserve_unknown_sections ||= !updating_major && (Bundler.settings[:frozen] || !@unlocking)
339
+ preserve_unknown_sections ||= !updating_major && (Bundler.frozen? || !(unlocking? || @unlocking_bundler))
315
340
  return if lockfiles_equal?(@lockfile_contents, contents, preserve_unknown_sections)
316
341
 
317
- if Bundler.settings[:frozen]
342
+ if Bundler.frozen?
318
343
  Bundler.ui.error "Cannot write a changed lockfile while frozen."
319
344
  return
320
345
  end
@@ -354,51 +379,8 @@ module Bundler
354
379
  end
355
380
 
356
381
  def to_lock
357
- out = String.new
358
-
359
- sources.lock_sources.each do |source|
360
- # Add the source header
361
- out << source.to_lock
362
- # Find all specs for this source
363
- resolve.
364
- select {|s| source.can_lock?(s) }.
365
- # This needs to be sorted by full name so that
366
- # gems with the same name, but different platform
367
- # are ordered consistently
368
- sort_by(&:full_name).
369
- each do |spec|
370
- next if spec.name == "bundler"
371
- out << spec.to_lock
372
- end
373
- out << "\n"
374
- end
375
-
376
- out << "PLATFORMS\n"
377
-
378
- platforms.map(&:to_s).sort.each do |p|
379
- out << " #{p}\n"
380
- end
381
-
382
- out << "\n"
383
- out << "DEPENDENCIES\n"
384
-
385
- handled = []
386
- dependencies.sort_by(&:to_s).each do |dep|
387
- next if handled.include?(dep.name)
388
- out << dep.to_lock
389
- handled << dep.name
390
- end
391
-
392
- if locked_ruby_version
393
- out << "\nRUBY VERSION\n"
394
- out << " #{locked_ruby_version}\n"
395
- end
396
-
397
- # Record the version of Bundler that was used to create the lockfile
398
- out << "\nBUNDLED WITH\n"
399
- out << " #{locked_bundler_version}\n"
400
-
401
- out
382
+ require "bundler/lockfile_generator"
383
+ LockfileGenerator.generate(self)
402
384
  end
403
385
 
404
386
  def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
@@ -408,8 +390,15 @@ module Bundler
408
390
  "updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control."
409
391
 
410
392
  unless explicit_flag
393
+ suggested_command = if Bundler.settings.locations("frozen")[:global]
394
+ "bundle config --delete frozen"
395
+ elsif Bundler.settings.locations("deployment").keys.&([:global, :local]).any?
396
+ "bundle config --delete deployment"
397
+ else
398
+ "bundle install --no-deployment"
399
+ end
411
400
  msg << "\n\nIf this is a development machine, remove the #{Bundler.default_gemfile} " \
412
- "freeze \nby running `bundle install --no-deployment`."
401
+ "freeze \nby running `#{suggested_command}`."
413
402
  end
414
403
 
415
404
  added = []
@@ -426,13 +415,13 @@ module Bundler
426
415
  new_sources = gemfile_sources - @locked_sources
427
416
  deleted_sources = @locked_sources - gemfile_sources
428
417
 
429
- new_deps = @dependencies - @locked_deps
430
- deleted_deps = @locked_deps - @dependencies
418
+ new_deps = @dependencies - @locked_deps.values
419
+ deleted_deps = @locked_deps.values - @dependencies
431
420
 
432
421
  # Check if it is possible that the source is only changed thing
433
422
  if (new_deps.empty? && deleted_deps.empty?) && (!new_sources.empty? && !deleted_sources.empty?)
434
- new_sources.reject! {|source| source.is_a_path? && source.path.exist? }
435
- deleted_sources.reject! {|source| source.is_a_path? && source.path.exist? }
423
+ new_sources.reject! {|source| (source.path? && source.path.exist?) || equivalent_rubygems_remotes?(source) }
424
+ deleted_sources.reject! {|source| (source.path? && source.path.exist?) || equivalent_rubygems_remotes?(source) }
436
425
  end
437
426
 
438
427
  if @locked_sources != gemfile_sources
@@ -452,7 +441,7 @@ module Bundler
452
441
 
453
442
  both_sources = Hash.new {|h, k| h[k] = [] }
454
443
  @dependencies.each {|d| both_sources[d.name][0] = d }
455
- @locked_deps.each {|d| both_sources[d.name][1] = d.source }
444
+ @locked_deps.each {|name, d| both_sources[name][1] = d.source }
456
445
 
457
446
  both_sources.each do |name, (dep, lock_source)|
458
447
  next unless (dep.nil? && !lock_source.nil?) || (!dep.nil? && !lock_source.nil? && !lock_source.can_lock?(dep))
@@ -461,12 +450,14 @@ module Bundler
461
450
  changed << "* #{name} from `#{gemfile_source_name}` to `#{lockfile_source_name}`"
462
451
  end
463
452
 
453
+ reason = change_reason
454
+ msg << "\n\n#{reason.split(", ").map(&:capitalize).join("\n")}" unless reason.strip.empty?
464
455
  msg << "\n\nYou have added to the Gemfile:\n" << added.join("\n") if added.any?
465
456
  msg << "\n\nYou have deleted from the Gemfile:\n" << deleted.join("\n") if deleted.any?
466
457
  msg << "\n\nYou have changed in the Gemfile:\n" << changed.join("\n") if changed.any?
467
458
  msg << "\n"
468
459
 
469
- raise ProductionError, msg if added.any? || deleted.any? || changed.any?
460
+ raise ProductionError, msg if added.any? || deleted.any? || changed.any? || !nothing_changed?
470
461
  end
471
462
 
472
463
  def validate_runtime!
@@ -523,7 +514,7 @@ module Bundler
523
514
 
524
515
  def add_current_platform
525
516
  current_platform = Bundler.local_platform
526
- add_platform(current_platform) if Bundler.settings[:specific_platform]
517
+ add_platform(current_platform) if Bundler.feature_flag.specific_platform?
527
518
  add_platform(generic(current_platform))
528
519
  end
529
520
 
@@ -538,14 +529,18 @@ module Bundler
538
529
  attr_reader :sources
539
530
  private :sources
540
531
 
541
- private
542
-
543
532
  def nothing_changed?
544
533
  !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes
545
534
  end
546
535
 
536
+ def unlocking?
537
+ @unlocking
538
+ end
539
+
540
+ private
541
+
547
542
  def change_reason
548
- if @unlocking
543
+ if unlocking?
549
544
  unlock_reason = @unlock.reject {|_k, v| Array(v).empty? }.map do |k, v|
550
545
  if v == true
551
546
  k.to_s
@@ -566,10 +561,7 @@ module Bundler
566
561
  end
567
562
 
568
563
  def pretty_dep(dep, source = false)
569
- msg = String.new(dep.name)
570
- msg << " (#{dep.requirement})" unless dep.requirement == Gem::Requirement.default
571
- msg << " from the `#{dep.source}` source" if source && dep.source
572
- msg
564
+ SharedHelpers.pretty_dependency(dep, source)
573
565
  end
574
566
 
575
567
  # Check if the specs of the given source changed
@@ -582,7 +574,7 @@ module Bundler
582
574
 
583
575
  def dependencies_for_source_changed?(source, locked_source = source)
584
576
  deps_for_source = @dependencies.select {|s| s.source == source }
585
- locked_deps_for_source = @locked_deps.select {|s| s.source == locked_source }
577
+ locked_deps_for_source = @locked_deps.values.select {|dep| dep.source == locked_source }
586
578
 
587
579
  Set.new(deps_for_source) != Set.new(locked_deps_for_source)
588
580
  end
@@ -591,7 +583,11 @@ module Bundler
591
583
  locked_index = Index.new
592
584
  locked_index.use(@locked_specs.select {|s| source.can_lock?(s) })
593
585
 
594
- source.specs != locked_index
586
+ # order here matters, since Index#== is checking source.specs.include?(locked_index)
587
+ locked_index != source.specs
588
+ rescue PathError, GitError => e
589
+ Bundler.ui.debug "Assuming that #{source} has not changed since fetching its specs errored (#{e})"
590
+ false
595
591
  end
596
592
 
597
593
  # Get all locals and override their matching sources.
@@ -627,29 +623,44 @@ module Bundler
627
623
  gemspec_source || source
628
624
  end
629
625
 
630
- def converge_sources
631
- changes = false
632
-
626
+ def converge_path_sources_to_gemspec_sources
633
627
  @locked_sources.map! do |source|
634
628
  converge_path_source_to_gemspec_source(source)
635
629
  end
636
630
  @locked_specs.each do |spec|
637
631
  spec.source &&= converge_path_source_to_gemspec_source(spec.source)
638
632
  end
633
+ @locked_deps.each do |_, dep|
634
+ dep.source &&= converge_path_source_to_gemspec_source(dep.source)
635
+ end
636
+ end
637
+
638
+ def converge_rubygems_sources
639
+ return false if Bundler.feature_flag.lockfile_uses_separate_rubygems_sources?
639
640
 
640
- # Get the Rubygems sources from the Gemfile.lock
641
+ changes = false
642
+
643
+ # Get the RubyGems sources from the Gemfile.lock
641
644
  locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) }
642
- # Get the Rubygems remotes from the Gemfile
645
+ # Get the RubyGems remotes from the Gemfile
643
646
  actual_remotes = sources.rubygems_remotes
644
647
 
645
- # If there is a Rubygems source in both
648
+ # If there is a RubyGems source in both
646
649
  if !locked_gem_sources.empty? && !actual_remotes.empty?
647
650
  locked_gem_sources.each do |locked_gem|
648
651
  # Merge the remotes from the Gemfile into the Gemfile.lock
649
- changes |= locked_gem.replace_remotes(actual_remotes)
652
+ changes |= locked_gem.replace_remotes(actual_remotes, Bundler.settings[:allow_deployment_source_credential_changes])
650
653
  end
651
654
  end
652
655
 
656
+ changes
657
+ end
658
+
659
+ def converge_sources
660
+ changes = false
661
+
662
+ changes |= converge_rubygems_sources
663
+
653
664
  # Replace the sources from the Gemfile with the sources from the Gemfile.lock,
654
665
  # if they exist in the Gemfile.lock and are `==`. If you can't find an equivalent
655
666
  # source in the Gemfile.lock, use the one from the Gemfile.
@@ -671,11 +682,12 @@ module Bundler
671
682
  end
672
683
 
673
684
  def converge_dependencies
674
- (@dependencies + @locked_deps).each do |dep|
675
- locked_source = @locked_deps.select {|d| d.name == dep.name }.last
685
+ frozen = Bundler.frozen?
686
+ (@dependencies + @locked_deps.values).each do |dep|
687
+ locked_source = @locked_deps[dep.name]
676
688
  # This is to make sure that if bundler is installing in deployment mode and
677
689
  # after locked_source and sources don't match, we still use locked_source.
678
- if Bundler.settings[:frozen] && !locked_source.nil? &&
690
+ if frozen && !locked_source.nil? &&
679
691
  locked_source.respond_to?(:source) && locked_source.source.instance_of?(Source::Path) && locked_source.source.path.exist?
680
692
  dep.source = locked_source.source
681
693
  elsif dep.source
@@ -685,7 +697,31 @@ module Bundler
685
697
  dep.platforms.concat(@platforms.map {|p| Dependency::REVERSE_PLATFORM_MAP[p] }.flatten(1)).uniq!
686
698
  end
687
699
  end
688
- Set.new(@dependencies) != Set.new(@locked_deps)
700
+
701
+ changes = false
702
+ # We want to know if all match, but don't want to check all entries
703
+ # This means we need to return false if any dependency doesn't match
704
+ # the lock or doesn't exist in the lock.
705
+ @dependencies.each do |dependency|
706
+ unless locked_dep = @locked_deps[dependency.name]
707
+ changes = true
708
+ next
709
+ end
710
+
711
+ # Gem::Dependency#== matches Gem::Dependency#type. As the lockfile
712
+ # doesn't carry a notion of the dependency type, if you use
713
+ # add_development_dependency in a gemspec that's loaded with the gemspec
714
+ # directive, the lockfile dependencies and resolved dependencies end up
715
+ # with a mismatch on #type. Work around that by setting the type on the
716
+ # dep from the lockfile.
717
+ locked_dep.instance_variable_set(:@type, dependency.type)
718
+
719
+ # We already know the name matches from the hash lookup
720
+ # so we only need to check the requirement now
721
+ changes ||= dependency.requirement != locked_dep.requirement
722
+ end
723
+
724
+ changes
689
725
  end
690
726
 
691
727
  # Remove elements from the locked specs that are expired. This will most
@@ -698,12 +734,11 @@ module Bundler
698
734
  # and Gemfile.lock. If the Gemfile modified a dependency, but
699
735
  # the gem in the Gemfile.lock still satisfies it, this is fine
700
736
  # too.
701
- locked_deps_hash = @locked_deps.inject({}) do |hsh, dep|
702
- hsh[dep] = dep
703
- hsh
704
- end
705
737
  @dependencies.each do |dep|
706
- locked_dep = locked_deps_hash[dep]
738
+ locked_dep = @locked_deps[dep.name]
739
+
740
+ # If the locked_dep doesn't match the dependency we're looking for then we ignore the locked_dep
741
+ locked_dep = nil unless locked_dep == dep
707
742
 
708
743
  if in_locked_deps?(dep, locked_dep) || satisfies_locked_spec?(dep)
709
744
  deps << dep
@@ -717,6 +752,8 @@ module Bundler
717
752
  end
718
753
  end
719
754
 
755
+ unlock_source_unlocks_spec = Bundler.feature_flag.unlock_source_unlocks_spec?
756
+
720
757
  converged = []
721
758
  @locked_specs.each do |s|
722
759
  # Replace the locked dependency's source with the equivalent source from the Gemfile
@@ -724,42 +761,58 @@ module Bundler
724
761
  s.source = (dep && dep.source) || sources.get(s.source)
725
762
 
726
763
  # Don't add a spec to the list if its source is expired. For example,
727
- # if you change a Git gem to Rubygems.
728
- next if s.source.nil? || @unlock[:sources].include?(s.source.name)
764
+ # if you change a Git gem to RubyGems.
765
+ next if s.source.nil?
766
+ next if @unlock[:sources].include?(s.source.name)
729
767
 
730
768
  # XXX This is a backwards-compatibility fix to preserve the ability to
731
769
  # unlock a single gem by passing its name via `--source`. See issue #3759
732
- next if s.source.nil? || @unlock[:sources].include?(s.name)
770
+ # TODO: delete in Bundler 2
771
+ next if unlock_source_unlocks_spec && @unlock[:sources].include?(s.name)
733
772
 
734
773
  # If the spec is from a path source and it doesn't exist anymore
735
774
  # then we unlock it.
736
775
 
737
776
  # Path sources have special logic
738
777
  if s.source.instance_of?(Source::Path) || s.source.instance_of?(Source::Gemspec)
739
- other = s.source.specs[s].first
778
+ other_sources_specs = begin
779
+ s.source.specs
780
+ rescue PathError, GitError
781
+ # if we won't need the source (according to the lockfile),
782
+ # don't error if the path/git source isn't available
783
+ next if @locked_specs.
784
+ for(requested_dependencies, [], false, true, false).
785
+ none? {|locked_spec| locked_spec.source == s.source }
786
+
787
+ raise
788
+ end
789
+
790
+ other = other_sources_specs[s].first
740
791
 
741
792
  # If the spec is no longer in the path source, unlock it. This
742
793
  # commonly happens if the version changed in the gemspec
743
794
  next unless other
744
795
 
745
796
  deps2 = other.dependencies.select {|d| d.type != :development }
797
+ runtime_dependencies = s.dependencies.select {|d| d.type != :development }
746
798
  # If the dependencies of the path source have changed, unlock it
747
- next unless s.dependencies.sort == deps2.sort
799
+ next unless runtime_dependencies.sort == deps2.sort
748
800
  end
749
801
 
750
802
  converged << s
751
803
  end
752
804
 
753
805
  resolve = SpecSet.new(converged)
754
- resolve = resolve.for(expand_dependencies(deps, true), @unlock[:gems])
755
- diff = @locked_specs.to_a - resolve.to_a
806
+ resolve = resolve.for(expand_dependencies(deps, true), @unlock[:gems], false, false, false)
807
+ diff = nil
756
808
 
757
809
  # Now, we unlock any sources that do not have anymore gems pinned to it
758
810
  sources.all_sources.each do |source|
759
811
  next unless source.respond_to?(:unlock!)
760
812
 
761
813
  unless resolve.any? {|s| s.source == source }
762
- source.unlock! if !diff.empty? && diff.any? {|s| s.source == source }
814
+ diff ||= @locked_specs.to_a - resolve.to_a
815
+ source.unlock! if diff.any? {|s| s.source == source }
763
816
  end
764
817
  end
765
818
 
@@ -774,24 +827,28 @@ module Bundler
774
827
  end
775
828
 
776
829
  def satisfies_locked_spec?(dep)
777
- @locked_specs.any? {|s| s.satisfies?(dep) && (!dep.source || s.source.include?(dep.source)) }
830
+ @locked_specs[dep].any? {|s| s.satisfies?(dep) && (!dep.source || s.source.include?(dep.source)) }
778
831
  end
779
832
 
780
833
  # This list of dependencies is only used in #resolve, so it's OK to add
781
834
  # the metadata dependencies here
782
835
  def expanded_dependencies
783
836
  @expanded_dependencies ||= begin
837
+ expand_dependencies(dependencies + metadata_dependencies, @remote)
838
+ end
839
+ end
840
+
841
+ def metadata_dependencies
842
+ @metadata_dependencies ||= begin
784
843
  ruby_versions = concat_ruby_version_requirements(@ruby_version)
785
844
  if ruby_versions.empty? || !@ruby_version.exact?
786
845
  concat_ruby_version_requirements(RubyVersion.system)
787
846
  concat_ruby_version_requirements(locked_ruby_version_object) unless @unlock[:ruby]
788
847
  end
789
-
790
- metadata_dependencies = [
848
+ [
791
849
  Dependency.new("ruby\0", ruby_versions),
792
850
  Dependency.new("rubygems\0", Gem::VERSION),
793
851
  ]
794
- expand_dependencies(dependencies + metadata_dependencies, @remote)
795
852
  end
796
853
  end
797
854
 
@@ -812,17 +869,20 @@ module Bundler
812
869
  end
813
870
 
814
871
  def expand_dependencies(dependencies, remote = false)
872
+ sorted_platforms = Resolver.sort_platforms(@platforms)
815
873
  deps = []
816
874
  dependencies.each do |dep|
817
875
  dep = Dependency.new(dep, ">= 0") unless dep.respond_to?(:name)
818
876
  next if !remote && !dep.current_platform?
819
- platforms = dep.gem_platforms(@platforms)
877
+ platforms = dep.gem_platforms(sorted_platforms)
820
878
  if platforms.empty?
879
+ mapped_platforms = dep.platforms.map {|p| Dependency::PLATFORM_MAP[p] }
821
880
  Bundler.ui.warn \
822
881
  "The dependency #{dep} will be unused by any of the platforms Bundler is installing for. " \
823
882
  "Bundler is installing for #{@platforms.join ", "} but the dependency " \
824
- "is only for #{dep.platforms.map {|p| Dependency::PLATFORM_MAP[p] }.join ", "}. " \
825
- "To add those platforms to the bundle, run `bundle lock --add-platform #{dep.platforms.join ", "}`."
883
+ "is only for #{mapped_platforms.join ", "}. " \
884
+ "To add those platforms to the bundle, " \
885
+ "run `bundle lock --add-platform #{mapped_platforms.join " "}`."
826
886
  end
827
887
  platforms.each do |p|
828
888
  deps << DepProxy.new(dep, p) if remote || p == generic_local_platform
@@ -844,30 +904,33 @@ module Bundler
844
904
  # Record the specs available in each gem's source, so that those
845
905
  # specs will be available later when the resolver knows where to
846
906
  # look for that gemspec (or its dependencies)
847
- source_requirements = {}
907
+ default = sources.default_source
908
+ source_requirements = { :default => default }
909
+ default = nil unless Bundler.feature_flag.lockfile_uses_separate_rubygems_sources?
848
910
  dependencies.each do |dep|
849
- next unless dep.source
850
- source_requirements[dep.name] = dep.source.specs
911
+ next unless source = dep.source || default
912
+ source_requirements[dep.name] = source
913
+ end
914
+ metadata_dependencies.each do |dep|
915
+ source_requirements[dep.name] = sources.metadata_source
851
916
  end
917
+ source_requirements["bundler"] = sources.metadata_source # needs to come last to override
852
918
  source_requirements
853
919
  end
854
920
 
855
- def pinned_spec_names(specs)
856
- names = []
857
- specs.each do |s|
858
- # TODO: when two sources without blocks is an error, we can change
859
- # this check to !s.source.is_a?(Source::LocalRubygems). For now,
860
- # we need to ask every Rubygems for every gem name.
861
- if s.source.is_a?(Source::Git) || s.source.is_a?(Source::Path)
862
- names << s.name
863
- end
921
+ def pinned_spec_names(skip = nil)
922
+ pinned_names = []
923
+ default = Bundler.feature_flag.lockfile_uses_separate_rubygems_sources? && sources.default_source
924
+ @dependencies.each do |dep|
925
+ next unless dep_source = dep.source || default
926
+ next if dep_source == skip
927
+ pinned_names << dep.name
864
928
  end
865
- names.uniq!
866
- names
929
+ pinned_names
867
930
  end
868
931
 
869
932
  def requested_groups
870
- groups - Bundler.settings.without - @optional_groups + Bundler.settings.with
933
+ groups - Bundler.settings[:without] - @optional_groups + Bundler.settings[:with]
871
934
  end
872
935
 
873
936
  def lockfiles_equal?(current, proposed, preserve_unknown_sections)
@@ -902,11 +965,20 @@ module Bundler
902
965
 
903
966
  def additional_base_requirements_for_resolve
904
967
  return [] unless @locked_gems && Bundler.feature_flag.only_update_to_newer_versions?
968
+ dependencies_by_name = dependencies.group_by(&:name)
905
969
  @locked_gems.specs.reduce({}) do |requirements, locked_spec|
906
- dep = Gem::Dependency.new(locked_spec.name, ">= #{locked_spec.version}")
907
- requirements[locked_spec.name] = DepProxy.new(dep, locked_spec.platform)
970
+ name = locked_spec.name
971
+ next requirements if @locked_deps[name] != dependencies_by_name[name]
972
+ dep = Gem::Dependency.new(name, ">= #{locked_spec.version}")
973
+ requirements[name] = DepProxy.new(dep, locked_spec.platform)
908
974
  requirements
909
975
  end.values
910
976
  end
977
+
978
+ def equivalent_rubygems_remotes?(source)
979
+ return false unless source.is_a?(Source::Rubygems)
980
+
981
+ Bundler.settings[:allow_deployment_source_credential_changes] && source.equivalent_remotes?(sources.rubygems_remotes)
982
+ end
911
983
  end
912
984
  end