bundler 2.2.7 → 2.2.17

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

Potentially problematic release.


This version of bundler might be problematic. Click here for more details.

Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +132 -5
  3. data/lib/bundler.rb +1 -1
  4. data/lib/bundler/build_metadata.rb +2 -2
  5. data/lib/bundler/cli.rb +4 -2
  6. data/lib/bundler/cli/common.rb +15 -2
  7. data/lib/bundler/cli/gem.rb +43 -17
  8. data/lib/bundler/cli/outdated.rb +1 -1
  9. data/lib/bundler/compact_index_client/updater.rb +10 -6
  10. data/lib/bundler/current_ruby.rb +1 -0
  11. data/lib/bundler/definition.rb +63 -58
  12. data/lib/bundler/dsl.rb +36 -25
  13. data/lib/bundler/feature_flag.rb +0 -1
  14. data/lib/bundler/fetcher.rb +2 -1
  15. data/lib/bundler/fetcher/downloader.rb +8 -4
  16. data/lib/bundler/gem_helper.rb +16 -0
  17. data/lib/bundler/index.rb +6 -5
  18. data/lib/bundler/injector.rb +2 -2
  19. data/lib/bundler/inline.rb +2 -1
  20. data/lib/bundler/installer.rb +2 -0
  21. data/lib/bundler/installer/parallel_installer.rb +36 -15
  22. data/lib/bundler/installer/standalone.rb +2 -1
  23. data/lib/bundler/lazy_specification.rb +14 -18
  24. data/lib/bundler/lockfile_parser.rb +3 -13
  25. data/lib/bundler/man/bundle-add.1 +1 -1
  26. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  27. data/lib/bundler/man/bundle-cache.1 +1 -1
  28. data/lib/bundler/man/bundle-check.1 +1 -1
  29. data/lib/bundler/man/bundle-clean.1 +1 -1
  30. data/lib/bundler/man/bundle-config.1 +25 -8
  31. data/lib/bundler/man/bundle-config.1.ronn +29 -10
  32. data/lib/bundler/man/bundle-doctor.1 +1 -1
  33. data/lib/bundler/man/bundle-exec.1 +1 -1
  34. data/lib/bundler/man/bundle-gem.1 +1 -1
  35. data/lib/bundler/man/bundle-info.1 +1 -1
  36. data/lib/bundler/man/bundle-init.1 +1 -1
  37. data/lib/bundler/man/bundle-inject.1 +1 -1
  38. data/lib/bundler/man/bundle-install.1 +1 -1
  39. data/lib/bundler/man/bundle-list.1 +1 -1
  40. data/lib/bundler/man/bundle-lock.1 +1 -1
  41. data/lib/bundler/man/bundle-open.1 +1 -1
  42. data/lib/bundler/man/bundle-outdated.1 +1 -1
  43. data/lib/bundler/man/bundle-platform.1 +1 -1
  44. data/lib/bundler/man/bundle-pristine.1 +1 -1
  45. data/lib/bundler/man/bundle-remove.1 +1 -1
  46. data/lib/bundler/man/bundle-show.1 +1 -1
  47. data/lib/bundler/man/bundle-update.1 +1 -1
  48. data/lib/bundler/man/bundle-viz.1 +1 -1
  49. data/lib/bundler/man/bundle.1 +1 -1
  50. data/lib/bundler/man/gemfile.5 +1 -1
  51. data/lib/bundler/plugin.rb +3 -2
  52. data/lib/bundler/plugin/api/source.rb +7 -0
  53. data/lib/bundler/plugin/installer.rb +8 -10
  54. data/lib/bundler/plugin/source_list.rb +4 -0
  55. data/lib/bundler/resolver.rb +82 -65
  56. data/lib/bundler/resolver/spec_group.rb +53 -38
  57. data/lib/bundler/retry.rb +1 -1
  58. data/lib/bundler/rubygems_gem_installer.rb +47 -0
  59. data/lib/bundler/settings.rb +60 -10
  60. data/lib/bundler/shared_helpers.rb +2 -2
  61. data/lib/bundler/source.rb +6 -0
  62. data/lib/bundler/source/metadata.rb +0 -4
  63. data/lib/bundler/source/path.rb +3 -1
  64. data/lib/bundler/source/path/installer.rb +1 -1
  65. data/lib/bundler/source/rubygems.rb +22 -6
  66. data/lib/bundler/source_list.rb +29 -24
  67. data/lib/bundler/spec_set.rb +22 -8
  68. data/lib/bundler/stub_specification.rb +8 -0
  69. data/lib/bundler/templates/Gemfile +1 -1
  70. data/lib/bundler/templates/gems.rb +1 -1
  71. data/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  72. data/lib/bundler/templates/newgem/README.md.tt +5 -3
  73. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +2 -4
  74. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -1
  75. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +11 -5
  76. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +1 -1
  77. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +1 -1
  78. data/lib/bundler/vendor/thor/lib/thor.rb +5 -6
  79. data/lib/bundler/vendor/thor/lib/thor/actions.rb +1 -1
  80. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +4 -2
  81. data/lib/bundler/vendor/thor/lib/thor/error.rb +1 -1
  82. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +5 -1
  83. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +9 -8
  84. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +5 -2
  85. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +5 -1
  86. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  87. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +1 -1
  88. data/lib/bundler/version.rb +1 -1
  89. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f8e9970b2d4991ebf1dd972107e05ecd32951bdfa797ed6c36d6abf7a703ea1
4
- data.tar.gz: 0d0ecd48d724a845003397e3ecb2bd063a2ab666522e3c37806175ecfe6a02f3
3
+ metadata.gz: 2c654f563fcfd784d65d2441b1cf8b5384f9e90ff8d7107de070e33dba2ee729
4
+ data.tar.gz: 4554510c934d22551680c26ff77f0b1a1073f7d35c0b21030d103fd40ade6baf
5
5
  SHA512:
6
- metadata.gz: 345c9fdec8f29fdc67469a1d8cda01428120c1dc87c5db079449c388d02f3779942403ee719737ec8b95b9cd2fd0d0a06a6f26b2aa2d5c354aacff97a6ba8baa
7
- data.tar.gz: 0aad39443512928b799c817eb78641e2bb7e0637937f26894ceda1bb250292fd5be44e0e61e714679bd07cac8ded827f6107934f90511ef00547837fa3292e8a
6
+ metadata.gz: c4c62c6eb0c7fc78acc3317de4dbaed2d26de9859bffd8930a08e7368829a4acb9f1bea24ad290a57124983bab8ac372da21573b742f50f4d36fa6a054406189
7
+ data.tar.gz: 1862e00690b660a6d872324c6e2819c29a48ee9e9d7d97bd0cf35a92f0ea7d008fd4f7921c3f917564a3fc3279ead82bf24a360f80ad63205b37e50975b232c9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,130 @@
1
+ # 2.2.17 (May 5, 2021)
2
+
3
+ ## Enhancements:
4
+
5
+ - Improve authentication required error message to include an alternative using `ENV` [#4565](https://github.com/rubygems/rubygems/pull/4565)
6
+ - Discard partial range responses without etag [#4563](https://github.com/rubygems/rubygems/pull/4563)
7
+ - Fix configuring ENV for a gem server with a name including dashes [#4571](https://github.com/rubygems/rubygems/pull/4571)
8
+ - Redact credentials from `bundle env` and `bundle config` [#4566](https://github.com/rubygems/rubygems/pull/4566)
9
+ - Redact all sources in verbose mode [#4564](https://github.com/rubygems/rubygems/pull/4564)
10
+ - Improve `bundle pristine` error if `BUNDLE_GEMFILE` does not exist [#4536](https://github.com/rubygems/rubygems/pull/4536)
11
+ - [CurrentRuby] Add 3.0 as a known minor [#4535](https://github.com/rubygems/rubygems/pull/4535)
12
+ - Prefer File.read instead of IO.read [#4530](https://github.com/rubygems/rubygems/pull/4530)
13
+ - Add space after open curly bracket in Gemfile and gems.rb template [#4518](https://github.com/rubygems/rubygems/pull/4518)
14
+
15
+ ## Bug fixes:
16
+
17
+ - Make sure specs are fetched from the right source when materializing [#4562](https://github.com/rubygems/rubygems/pull/4562)
18
+ - Fix `bundle cache` with an up-to-date lockfile and specs not already installed [#4554](https://github.com/rubygems/rubygems/pull/4554)
19
+ - Ignore `deployment` setting in inline mode [#4523](https://github.com/rubygems/rubygems/pull/4523)
20
+
21
+ ## Performance:
22
+
23
+ - Don't materialize resolutions when not necessary [#4556](https://github.com/rubygems/rubygems/pull/4556)
24
+
25
+ # 2.2.16 (April 8, 2021)
26
+
27
+ ## Enhancements:
28
+
29
+ - Add `--github-username` option and config to `bundle gem` [#3687](https://github.com/rubygems/rubygems/pull/3687)
30
+ - Bump vendored `tmpdir` library copy [#4506](https://github.com/rubygems/rubygems/pull/4506)
31
+ - Add `rake build:checksum` task to build checksums for a gem package [#4156](https://github.com/rubygems/rubygems/pull/4156)
32
+ - Enable bundler-cache for GitHub Actions template [#4498](https://github.com/rubygems/rubygems/pull/4498)
33
+ - Improve `bundle info` error when gem is on a "disabled" group [#4492](https://github.com/rubygems/rubygems/pull/4492)
34
+ - Small tweak to yank message [#4494](https://github.com/rubygems/rubygems/pull/4494)
35
+ - Don't show duplicate entries in `bundle outdated` output [#4474](https://github.com/rubygems/rubygems/pull/4474)
36
+ - Never downgrade top level gems when running `bundle update` [#4473](https://github.com/rubygems/rubygems/pull/4473)
37
+
38
+ ## Bug fixes:
39
+
40
+ - Fix incorrect logic for filtering metadata matching candidates [#4497](https://github.com/rubygems/rubygems/pull/4497)
41
+
42
+ # 2.2.15 (March 19, 2021)
43
+
44
+ ## Enhancements:
45
+
46
+ - Add a hint about bundler installing executables for path gems [#4461](https://github.com/rubygems/rubygems/pull/4461)
47
+ - Warn lockfiles with incorrect resolutions [#4459](https://github.com/rubygems/rubygems/pull/4459)
48
+ - Don't generate duplicate redundant sources in the lockfile [#4456](https://github.com/rubygems/rubygems/pull/4456)
49
+
50
+ ## Bug fixes:
51
+
52
+ - Respect running ruby when resolving platforms [#4449](https://github.com/rubygems/rubygems/pull/4449)
53
+
54
+ # 2.2.14 (March 8, 2021)
55
+
56
+ ## Security fixes:
57
+
58
+ - Lock GEM sources separately and fix locally installed specs confusing bundler [#4381](https://github.com/rubygems/rubygems/pull/4381)
59
+
60
+ ## Bug fixes:
61
+
62
+ - Make `rake` available to other gems' installers right after it's installed [#4428](https://github.com/rubygems/rubygems/pull/4428)
63
+ - Fix encoding issue on compact index updater [#4362](https://github.com/rubygems/rubygems/pull/4362)
64
+
65
+ # 2.2.13 (March 3, 2021)
66
+
67
+ ## Enhancements:
68
+
69
+ - Respect user configured default branch in README links in new generated gems [#4303](https://github.com/rubygems/rubygems/pull/4303)
70
+
71
+ ## Bug fixes:
72
+
73
+ - Fix gems sometimes being pulled from irrelevant sources [#4418](https://github.com/rubygems/rubygems/pull/4418)
74
+
75
+ # 2.2.12 (March 1, 2021)
76
+
77
+ ## Bug fixes:
78
+
79
+ - Fix sporadic warnings about `nil` gemspec on install/update and make those faster [#4409](https://github.com/rubygems/rubygems/pull/4409)
80
+ - Fix deployment install with duplicate path gems added to Gemfile [#4410](https://github.com/rubygems/rubygems/pull/4410)
81
+
82
+ # 2.2.11 (February 17, 2021)
83
+
84
+ ## Bug fixes:
85
+
86
+ - Revert disable_multisource changes [#4385](https://github.com/rubygems/rubygems/pull/4385)
87
+
88
+ # 2.2.10 (February 15, 2021)
89
+
90
+ ## Security fixes:
91
+
92
+ - Fix source priority for transitive dependencies and split lockfile rubygems source sections [#3655](https://github.com/rubygems/rubygems/pull/3655)
93
+
94
+ ## Bug fixes:
95
+
96
+ - Fix adding platforms to lockfile sometimes conflicting on ruby requirements [#4371](https://github.com/rubygems/rubygems/pull/4371)
97
+ - Fix bundler sometimes choosing ruby variants over java ones [#4367](https://github.com/rubygems/rubygems/pull/4367)
98
+
99
+ ## Documentation:
100
+
101
+ - Update man pages to reflect to new default for bundle install jobs [#4188](https://github.com/rubygems/rubygems/pull/4188)
102
+
103
+ # 2.2.9 (February 8, 2021)
104
+
105
+ ## Enhancements:
106
+
107
+ - Stop removing existing platforms when force_ruby_platform is true [#4336](https://github.com/rubygems/rubygems/pull/4336)
108
+
109
+ ## Bug fixes:
110
+
111
+ - Don't install platform specific gems on truffleruby [#4333](https://github.com/rubygems/rubygems/pull/4333)
112
+
113
+ # 2.2.8 (February 2, 2021)
114
+
115
+ ## Enhancements:
116
+
117
+ - Add a CHANGELOG.md file to gems generated by `bundle gem` [#4093](https://github.com/rubygems/rubygems/pull/4093)
118
+ - Support gemified `set` [#4297](https://github.com/rubygems/rubygems/pull/4297)
119
+
120
+ ## Bug fixes:
121
+
122
+ - Fix standalone Kernel.require visibility [#4337](https://github.com/rubygems/rubygems/pull/4337)
123
+
124
+ ## Performance:
125
+
126
+ - Fix resolver edge cases and speed up bundler [#4277](https://github.com/rubygems/rubygems/pull/4277)
127
+
1
128
  # 2.2.7 (January 26, 2021)
2
129
 
3
130
  ## Enhancements:
@@ -369,7 +496,7 @@
369
496
  - Ignore `frozen` setting in inline mode ([#7125](https://github.com/rubygems/bundler/pull/7125))
370
497
  - Fix incorrect "bundler attempted to update GEM but version stayed the same" message when updating git sourced gems ([#6325](https://github.com/rubygems/bundler/pull/6325))
371
498
  - Don't check for existence of a writable home directory if `BUNDLE_USER_HOME` is set ([#6885](https://github.com/rubygems/bundler/pull/6885))
372
- - Fix error message when server would respond to a bad username/password requiest with a 401 ([#6928](https://github.com/rubygems/bundler/pull/6928))
499
+ - Fix error message when server would respond to a bad username/password request with a 401 ([#6928](https://github.com/rubygems/bundler/pull/6928))
373
500
  - Fix `bundle outdated` pluralization when multiple groups are requested ([#7063](https://github.com/rubygems/bundler/pull/7063))
374
501
  - Fix `bundle install` not updating conservatively when gemspec is changed ([#7143](https://github.com/rubygems/bundler/pull/7143))
375
502
  - Fix `bundle exec` not respecting custom process titles inside scripts ([#7140](https://github.com/rubygems/bundler/pull/7140))
@@ -2014,7 +2141,7 @@ Changes
2014
2141
  - fix Bundler.which for directories ([#2697](https://github.com/rubygems/bundler/issues/2697), @rhysd)
2015
2142
  - properly require `Capistrano::Version` ([#2690](https://github.com/rubygems/bundler/issues/2690), @steveklabnik)
2016
2143
  - search for git.exe and git
2017
- - fix the bug that downloads every spec when API fetcher encouters an error
2144
+ - fix the bug that downloads every spec when API fetcher encounters an error
2018
2145
  - only retry network requests
2019
2146
 
2020
2147
  # 1.4.0.rc.1 (September 29, 2013)
@@ -2638,7 +2765,7 @@ Changes
2638
2765
 
2639
2766
  - Implement `to_ary` to avoid calls to method_missing (@tenderlove, [#1274](https://github.com/rubygems/bundler/issues/1274))
2640
2767
  - bundle clean removes old .gem files (@cldwalker, [#1293](https://github.com/rubygems/bundler/issues/1293))
2641
- - Correcly identify missing child dependency in error message
2768
+ - Correctly identify missing child dependency in error message
2642
2769
  - Run pre-install, post-build, and post-install gem hooks for git gems (@warhammerkid, [#1120](https://github.com/rubygems/bundler/issues/1120))
2643
2770
  - create Gemfile.lock for empty Gemfile ([#1218](https://github.com/rubygems/bundler/issues/1218))
2644
2771
 
@@ -2789,7 +2916,7 @@ Changes
2789
2916
 
2790
2917
  - Performance fix for MRI 1.9 (@efficientcloud, [#1288](https://github.com/rubygems/bundler/issues/1288))
2791
2918
  - Shortcuts (like `bundle i`) for all commands (@amatsuda)
2792
- - Correcly identify missing child dependency in error message
2919
+ - Correctly identify missing child dependency in error message
2793
2920
 
2794
2921
  ## Bug fixes:
2795
2922
 
@@ -3025,7 +3152,7 @@ Changes
3025
3152
 
3026
3153
  - Various bugfixes to the built-in rake helpers
3027
3154
  - Fix a bug where shortrefs weren't unique enough and were
3028
- therfore colliding
3155
+ therefore colliding
3029
3156
  - Fix a small bug involving checking whether a local git
3030
3157
  clone is up to date
3031
3158
  - Correctly handle explicit '=' dependencies with gems
data/lib/bundler.rb CHANGED
@@ -440,7 +440,7 @@ EOF
440
440
  end
441
441
 
442
442
  def local_platform
443
- return Gem::Platform::RUBY if settings[:force_ruby_platform]
443
+ return Gem::Platform::RUBY if settings[:force_ruby_platform] || Gem.platforms == [Gem::Platform::RUBY]
444
444
  Gem::Platform.local
445
445
  end
446
446
 
@@ -4,8 +4,8 @@ module Bundler
4
4
  # Represents metadata from when the Bundler gem was built.
5
5
  module BuildMetadata
6
6
  # begin ivars
7
- @built_at = "2021-01-27".freeze
8
- @git_commit_sha = "7bc7ecb660".freeze
7
+ @built_at = "2021-05-05".freeze
8
+ @git_commit_sha = "69cbd6e10e".freeze
9
9
  @release = true
10
10
  # end ivars
11
11
 
data/lib/bundler/cli.rb CHANGED
@@ -504,8 +504,8 @@ module Bundler
504
504
  By default, setting a configuration value sets it for all projects
505
505
  on the machine.
506
506
 
507
- If a global setting is superceded by local configuration, this command
508
- will show the current value, as well as any superceded values and
507
+ If a global setting is superseded by local configuration, this command
508
+ will show the current value, as well as any superseded values and
509
509
  where they were specified.
510
510
  D
511
511
  require_relative "cli/config"
@@ -586,10 +586,12 @@ module Bundler
586
586
  method_option :git, :type => :boolean, :default => true, :desc => "Initialize a git repo inside your library."
587
587
  method_option :mit, :type => :boolean, :desc => "Generate an MIT license file. Set a default with `bundle config set --global gem.mit true`."
588
588
  method_option :rubocop, :type => :boolean, :desc => "Add rubocop to the generated Rakefile and gemspec. Set a default with `bundle config set --global gem.rubocop true`."
589
+ method_option :changelog, :type => :boolean, :desc => "Generate changelog file. Set a default with `bundle config set --global gem.changelog true`."
589
590
  method_option :test, :type => :string, :lazy_default => Bundler.settings["gem.test"] || "", :aliases => "-t", :banner => "Use the specified test framework for your library",
590
591
  :desc => "Generate a test directory for your library, either rspec, minitest or test-unit. Set a default with `bundle config set --global gem.test (rspec|minitest|test-unit)`."
591
592
  method_option :ci, :type => :string, :lazy_default => Bundler.settings["gem.ci"] || "",
592
593
  :desc => "Generate CI configuration, either GitHub Actions, Travis CI, GitLab CI or CircleCI. Set a default with `bundle config set --global gem.ci (github|travis|gitlab|circle)`"
594
+ method_option :github_username, :type => :string, :default => Bundler.settings["gem.github_username"], :banner => "Set your username on GitHub", :desc => "Fill in GitHub username on README so that you don't have to do it manually. Set a default with `bundle config set --global gem.github_username <your_username>`."
593
595
 
594
596
  def gem(name)
595
597
  end
@@ -36,10 +36,15 @@ module Bundler
36
36
  def self.without_groups_message(command)
37
37
  command_in_past_tense = command == :install ? "installed" : "updated"
38
38
  groups = Bundler.settings[:without]
39
+ "Gems in the #{verbalize_groups(groups)} were not #{command_in_past_tense}."
40
+ end
41
+
42
+ def self.verbalize_groups(groups)
43
+ groups.map!{|g| "'#{g}'" }
39
44
  group_list = [groups[0...-1].join(", "), groups[-1..-1]].
40
45
  reject {|s| s.to_s.empty? }.join(" and ")
41
46
  group_str = groups.size == 1 ? "group" : "groups"
42
- "Gems in the #{group_str} #{group_list} were not #{command_in_past_tense}."
47
+ "#{group_str} #{group_list}"
43
48
  end
44
49
 
45
50
  def self.select_spec(name, regex_match = nil)
@@ -53,7 +58,13 @@ module Bundler
53
58
 
54
59
  case specs.count
55
60
  when 0
56
- raise GemNotFound, gem_not_found_message(name, Bundler.definition.dependencies)
61
+ dep_in_other_group = Bundler.definition.current_dependencies.find {|dep|dep.name == name }
62
+
63
+ if dep_in_other_group
64
+ raise GemNotFound, "Could not find gem '#{name}', because it's in the #{verbalize_groups(dep_in_other_group.groups)}, configured to be ignored."
65
+ else
66
+ raise GemNotFound, gem_not_found_message(name, Bundler.definition.dependencies)
67
+ end
57
68
  when 1
58
69
  specs.first
59
70
  else
@@ -83,6 +94,8 @@ module Bundler
83
94
  end
84
95
 
85
96
  def self.ensure_all_gems_in_lockfile!(names, locked_gems = Bundler.locked_gems)
97
+ return unless locked_gems
98
+
86
99
  locked_names = locked_gems.specs.map(&:name).uniq
87
100
  names.-(locked_names).each do |g|
88
101
  raise GemNotFound, gem_not_found_message(g, locked_names)
@@ -39,11 +39,19 @@ module Bundler
39
39
  constant_name = name.gsub(/-[_-]*(?![_-]|$)/) { "::" }.gsub(/([_-]+|(::)|^)(.|$)/) { $2.to_s + $3.upcase }
40
40
  constant_array = constant_name.split("::")
41
41
 
42
- git_installed = Bundler.git_present?
42
+ use_git = Bundler.git_present? && options[:git]
43
43
 
44
- git_author_name = git_installed ? `git config user.name`.chomp : ""
45
- github_username = git_installed ? `git config github.user`.chomp : ""
46
- git_user_email = git_installed ? `git config user.email`.chomp : ""
44
+ git_author_name = use_git ? `git config user.name`.chomp : ""
45
+ git_username = use_git ? `git config github.user`.chomp : ""
46
+ git_user_email = use_git ? `git config user.email`.chomp : ""
47
+
48
+ github_username = if options[:github_username].nil?
49
+ git_username
50
+ elsif options[:github_username] == false
51
+ ""
52
+ else
53
+ options[:github_username]
54
+ end
47
55
 
48
56
  config = {
49
57
  :name => name,
@@ -58,6 +66,7 @@ module Bundler
58
66
  :ext => options[:ext],
59
67
  :exe => options[:exe],
60
68
  :bundler_version => bundler_dependency_version,
69
+ :git => use_git,
61
70
  :github_username => github_username.empty? ? "[USERNAME]" : github_username,
62
71
  :required_ruby_version => Gem.ruby_version < Gem::Version.new("2.4.a") ? "2.3.0" : "2.4.0",
63
72
  }
@@ -79,7 +88,7 @@ module Bundler
79
88
  bin/setup
80
89
  ]
81
90
 
82
- templates.merge!("gitignore.tt" => ".gitignore") if Bundler.git_present?
91
+ templates.merge!("gitignore.tt" => ".gitignore") if use_git
83
92
 
84
93
  if test_framework = ask_and_set_test_framework
85
94
  config[:test] = test_framework
@@ -142,6 +151,18 @@ module Bundler
142
151
  templates.merge!("CODE_OF_CONDUCT.md.tt" => "CODE_OF_CONDUCT.md")
143
152
  end
144
153
 
154
+ if ask_and_set(:changelog, "Do you want to include a changelog?",
155
+ "A changelog is a file which contains a curated, chronologically ordered list of notable " \
156
+ "changes for each version of a project. To make it easier for users and contributors to" \
157
+ " see precisely what notable changes have been made between each release (or version) of" \
158
+ " the project. Whether consumers or developers, the end users of software are" \
159
+ " human beings who care about what's in the software. When the software changes, people " \
160
+ "want to know why and how. see https://keepachangelog.com")
161
+ config[:changelog] = true
162
+ Bundler.ui.info "Changelog enabled in config"
163
+ templates.merge!("CHANGELOG.md.tt" => "CHANGELOG.md")
164
+ end
165
+
145
166
  if ask_and_set(:rubocop, "Do you want to add rubocop as a dependency for gems you generate?",
146
167
  "RuboCop is a static code analyzer that has out-of-the-box rules for many " \
147
168
  "of the guidelines in the community style guide. " \
@@ -163,24 +184,31 @@ module Bundler
163
184
  )
164
185
  end
165
186
 
187
+ if File.exist?(target) && !File.directory?(target)
188
+ Bundler.ui.error "Couldn't create a new gem named `#{gem_name}` because there's an existing file named `#{gem_name}`."
189
+ exit Bundler::BundlerError.all_errors[Bundler::GenericSystemCallError]
190
+ end
191
+
192
+ if use_git
193
+ Bundler.ui.info "Initializing git repo in #{target}"
194
+ `git init #{target}`
195
+
196
+ config[:git_default_branch] = File.read("#{target}/.git/HEAD").split("/").last.chomp
197
+ end
198
+
166
199
  templates.each do |src, dst|
167
200
  destination = target.join(dst)
168
- SharedHelpers.filesystem_access(destination) do
169
- thor.template("newgem/#{src}", destination, config)
170
- end
201
+ thor.template("newgem/#{src}", destination, config)
171
202
  end
172
203
 
173
204
  executables.each do |file|
174
- SharedHelpers.filesystem_access(target.join(file)) do |path|
175
- executable = (path.stat.mode | 0o111)
176
- path.chmod(executable)
177
- end
205
+ path = target.join(file)
206
+ executable = (path.stat.mode | 0o111)
207
+ path.chmod(executable)
178
208
  end
179
209
 
180
- if Bundler.git_present? && options[:git]
181
- Bundler.ui.info "Initializing git repo in #{target}"
210
+ if use_git
182
211
  Dir.chdir(target) do
183
- `git init`
184
212
  `git add .`
185
213
  end
186
214
  end
@@ -190,8 +218,6 @@ module Bundler
190
218
 
191
219
  Bundler.ui.info "Gem '#{name}' was successfully created. " \
192
220
  "For more information on making a RubyGem visit https://bundler.io/guides/creating_gem.html"
193
- rescue Errno::EEXIST => e
194
- raise GenericSystemCallError.new(e, "There was a conflict while creating the new gem.")
195
221
  end
196
222
 
197
223
  private
@@ -72,7 +72,7 @@ module Bundler
72
72
  gemfile_specs + dependency_specs
73
73
  end
74
74
 
75
- specs.sort_by(&:name).each do |current_spec|
75
+ specs.sort_by(&:name).uniq(&:name).each do |current_spec|
76
76
  next unless gems.empty? || gems.include?(current_spec.name)
77
77
 
78
78
  active_spec = retrieve_active_spec(definition, current_spec)
@@ -50,16 +50,20 @@ module Bundler
50
50
 
51
51
  content = response.body
52
52
 
53
- SharedHelpers.filesystem_access(local_temp_path) do
53
+ etag = (response["ETag"] || "").gsub(%r{\AW/}, "")
54
+ correct_response = SharedHelpers.filesystem_access(local_temp_path) do
54
55
  if response.is_a?(Net::HTTPPartialContent) && local_temp_path.size.nonzero?
55
56
  local_temp_path.open("a") {|f| f << slice_body(content, 1..-1) }
57
+
58
+ etag_for(local_temp_path) == etag
56
59
  else
57
- local_temp_path.open("w") {|f| f << content }
60
+ local_temp_path.open("wb") {|f| f << content }
61
+
62
+ etag.length.zero? || etag_for(local_temp_path) == etag
58
63
  end
59
64
  end
60
65
 
61
- etag = (response["ETag"] || "").gsub(%r{\AW/}, "")
62
- if etag.length.zero? || etag_for(local_temp_path) == etag
66
+ if correct_response
63
67
  SharedHelpers.filesystem_access(local_path) do
64
68
  FileUtils.mv(local_temp_path, local_path)
65
69
  end
@@ -92,11 +96,11 @@ module Bundler
92
96
 
93
97
  def checksum_for_file(path)
94
98
  return nil unless path.file?
95
- # This must use IO.read instead of Digest.file().hexdigest
99
+ # This must use File.read instead of Digest.file().hexdigest
96
100
  # because we need to preserve \n line endings on windows when calculating
97
101
  # the checksum
98
102
  SharedHelpers.filesystem_access(path, :read) do
99
- SharedHelpers.digest(:MD5).hexdigest(IO.read(path))
103
+ SharedHelpers.digest(:MD5).hexdigest(File.read(path))
100
104
  end
101
105
  end
102
106
  end
@@ -20,6 +20,7 @@ module Bundler
20
20
  2.5
21
21
  2.6
22
22
  2.7
23
+ 3.0
23
24
  ].freeze
24
25
 
25
26
  KNOWN_MAJOR_VERSIONS = KNOWN_MINOR_VERSIONS.map {|v| v.split(".", 2).first }.uniq.freeze
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "lockfile_parser"
4
- require "set"
5
4
 
6
5
  module Bundler
7
6
  class Definition
@@ -83,11 +82,7 @@ module Bundler
83
82
  @lockfile_contents = Bundler.read_file(lockfile)
84
83
  @locked_gems = LockfileParser.new(@lockfile_contents)
85
84
  @locked_platforms = @locked_gems.platforms
86
- if Bundler.settings[:force_ruby_platform]
87
- @platforms = [Gem::Platform::RUBY]
88
- else
89
- @platforms = @locked_platforms.dup
90
- end
85
+ @platforms = @locked_platforms.dup
91
86
  @locked_bundler_version = @locked_gems.bundler_version
92
87
  @locked_ruby_version = @locked_gems.ruby_version
93
88
 
@@ -111,6 +106,17 @@ module Bundler
111
106
  @locked_platforms = []
112
107
  end
113
108
 
109
+ @locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) }
110
+ @disable_multisource = @locked_gem_sources.all?(&:disable_multisource?)
111
+
112
+ unless @disable_multisource
113
+ msg = "Your lockfile contains a single rubygems source section with multiple remotes, which is insecure. You should run `bundle update` or generate your lockfile from scratch."
114
+
115
+ Bundler::SharedHelpers.major_deprecation 2, msg
116
+
117
+ @sources.merged_gem_lockfile_sections!
118
+ end
119
+
114
120
  @unlock[:gems] ||= []
115
121
  @unlock[:sources] ||= []
116
122
  @unlock[:ruby] ||= if @ruby_version && locked_ruby_version_object
@@ -150,17 +156,19 @@ module Bundler
150
156
  end
151
157
  end
152
158
 
159
+ def disable_multisource?
160
+ @disable_multisource
161
+ end
162
+
153
163
  def resolve_with_cache!
154
- raise "Specs already loaded" if @specs
155
164
  sources.cached!
156
- specs
165
+ resolve
157
166
  end
158
167
 
159
168
  def resolve_remotely!
160
- return if @specs
161
169
  @remote = true
162
170
  sources.remote!
163
- specs
171
+ resolve
164
172
  end
165
173
 
166
174
  # For given dependency list returns a SpecSet with Gemspec of all the required
@@ -177,10 +185,10 @@ module Bundler
177
185
  gem_name, gem_version = extract_gem_info(e)
178
186
  locked_gem = @locked_specs[gem_name].last
179
187
  raise if locked_gem.nil? || locked_gem.version.to_s != gem_version || !@remote
180
- raise GemNotFound, "Your bundle is locked to #{locked_gem}, but that version could not " \
181
- "be found in any of the sources listed in your Gemfile. If you haven't changed sources, " \
182
- "that means the author of #{locked_gem} has removed it. You'll need to update your bundle " \
183
- "to a version other than #{locked_gem} that hasn't been removed in order to install."
188
+ raise GemNotFound, "Your bundle is locked to #{locked_gem} from #{locked_gem.source}, but that version can " \
189
+ "no longer be found in that source. That means the author of #{locked_gem} has removed it. " \
190
+ "You'll need to update your bundle to a version other than #{locked_gem} that hasn't been " \
191
+ "removed in order to install."
184
192
  end
185
193
  unless specs["bundler"].any?
186
194
  bundler = sources.metadata_source.specs.search(Gem::Dependency.new("bundler", VERSION)).last
@@ -259,23 +267,18 @@ module Bundler
259
267
  def resolve
260
268
  @resolve ||= begin
261
269
  last_resolve = converge_locked_specs
262
- resolve =
263
- if Bundler.frozen_bundle?
264
- Bundler.ui.debug "Frozen, using resolution from the lockfile"
265
- last_resolve
266
- elsif !unlocking? && nothing_changed?
267
- Bundler.ui.debug("Found no changes, using resolution from the lockfile")
268
- last_resolve
269
- else
270
- # Run a resolve against the locally available gems
271
- Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}")
272
- expanded_dependencies = expand_dependencies(dependencies + metadata_dependencies, @remote)
273
- last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
274
- end
275
-
276
- # filter out gems that _can_ be installed on multiple platforms, but don't need
277
- # to be
278
- resolve.for(expand_dependencies(dependencies, true), [], false, false, false)
270
+ if Bundler.frozen_bundle?
271
+ Bundler.ui.debug "Frozen, using resolution from the lockfile"
272
+ last_resolve
273
+ elsif !unlocking? && nothing_changed?
274
+ Bundler.ui.debug("Found no changes, using resolution from the lockfile")
275
+ last_resolve
276
+ else
277
+ # Run a resolve against the locally available gems
278
+ Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}")
279
+ expanded_dependencies = expand_dependencies(dependencies + metadata_dependencies, @remote)
280
+ Resolver.resolve(expanded_dependencies, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
281
+ end
279
282
  end
280
283
  end
281
284
 
@@ -540,6 +543,9 @@ module Bundler
540
543
  attr_reader :sources
541
544
  private :sources
542
545
 
546
+ attr_reader :locked_gem_sources
547
+ private :locked_gem_sources
548
+
543
549
  def nothing_changed?
544
550
  !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes && !@locked_specs_incomplete_for_platform
545
551
  end
@@ -604,7 +610,7 @@ module Bundler
604
610
  deps_for_source = @dependencies.select {|s| s.source == source }
605
611
  locked_deps_for_source = @locked_deps.values.select {|dep| dep.source == locked_source }
606
612
 
607
- Set.new(deps_for_source) != Set.new(locked_deps_for_source)
613
+ deps_for_source.uniq.sort != locked_deps_for_source.sort
608
614
  end
609
615
 
610
616
  def specs_for_source_changed?(source)
@@ -664,21 +670,20 @@ module Bundler
664
670
  end
665
671
 
666
672
  def converge_rubygems_sources
667
- return false if Bundler.feature_flag.disable_multisource?
673
+ return false if disable_multisource?
668
674
 
669
- changes = false
675
+ return false if locked_gem_sources.empty?
670
676
 
671
- # Get the RubyGems sources from the Gemfile.lock
672
- locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) }
673
677
  # Get the RubyGems remotes from the Gemfile
674
678
  actual_remotes = sources.rubygems_remotes
679
+ return false if actual_remotes.empty?
680
+
681
+ changes = false
675
682
 
676
683
  # If there is a RubyGems source in both
677
- if !locked_gem_sources.empty? && !actual_remotes.empty?
678
- locked_gem_sources.each do |locked_gem|
679
- # Merge the remotes from the Gemfile into the Gemfile.lock
680
- changes |= locked_gem.replace_remotes(actual_remotes, Bundler.settings[:allow_deployment_source_credential_changes])
681
- end
684
+ locked_gem_sources.each do |locked_gem|
685
+ # Merge the remotes from the Gemfile into the Gemfile.lock
686
+ changes |= locked_gem.replace_remotes(actual_remotes, Bundler.settings[:allow_deployment_source_credential_changes])
682
687
  end
683
688
 
684
689
  changes
@@ -884,7 +889,7 @@ module Bundler
884
889
  dependencies.each do |dep|
885
890
  dep = Dependency.new(dep, ">= 0") unless dep.respond_to?(:name)
886
891
  next unless remote || dep.current_platform?
887
- target_platforms = dep.gem_platforms(remote ? Resolver.sort_platforms(@platforms) : [generic_local_platform])
892
+ target_platforms = dep.gem_platforms(remote ? @platforms : [generic_local_platform])
888
893
  deps += expand_dependency_with_platforms(dep, target_platforms)
889
894
  end
890
895
  deps
@@ -903,30 +908,18 @@ module Bundler
903
908
  # Record the specs available in each gem's source, so that those
904
909
  # specs will be available later when the resolver knows where to
905
910
  # look for that gemspec (or its dependencies)
906
- default = sources.default_source
907
- source_requirements = { :default => default }
908
- default = nil unless Bundler.feature_flag.disable_multisource?
909
- dependencies.each do |dep|
910
- next unless source = dep.source || default
911
- source_requirements[dep.name] = source
912
- end
911
+ source_requirements = { :default => sources.default_source }.merge(dependency_source_requirements)
913
912
  metadata_dependencies.each do |dep|
914
913
  source_requirements[dep.name] = sources.metadata_source
915
914
  end
915
+ source_requirements[:global] = index unless Bundler.feature_flag.disable_multisource?
916
916
  source_requirements[:default_bundler] = source_requirements["bundler"] || source_requirements[:default]
917
917
  source_requirements["bundler"] = sources.metadata_source # needs to come last to override
918
918
  source_requirements
919
919
  end
920
920
 
921
921
  def pinned_spec_names(skip = nil)
922
- pinned_names = []
923
- default = Bundler.feature_flag.disable_multisource? && 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
928
- end
929
- pinned_names
922
+ dependency_source_requirements.reject {|_, source| source == skip }.keys
930
923
  end
931
924
 
932
925
  def requested_groups
@@ -964,7 +957,7 @@ module Bundler
964
957
  end
965
958
 
966
959
  def additional_base_requirements_for_resolve
967
- return [] unless @locked_gems && Bundler.feature_flag.only_update_to_newer_versions?
960
+ return [] unless @locked_gems
968
961
  dependencies_by_name = dependencies.inject({}) {|memo, dep| memo.update(dep.name => dep) }
969
962
  @locked_gems.specs.reduce({}) do |requirements, locked_spec|
970
963
  name = locked_spec.name
@@ -983,5 +976,17 @@ module Bundler
983
976
 
984
977
  Bundler.settings[:allow_deployment_source_credential_changes] && source.equivalent_remotes?(sources.rubygems_remotes)
985
978
  end
979
+
980
+ def dependency_source_requirements
981
+ @dependency_source_requirements ||= begin
982
+ source_requirements = {}
983
+ default = sources.default_source
984
+ dependencies.each do |dep|
985
+ dep_source = dep.source || default
986
+ source_requirements[dep.name] = dep_source
987
+ end
988
+ source_requirements
989
+ end
990
+ end
986
991
  end
987
992
  end