diff options
| author | Earlopain <14981592+Earlopain@users.noreply.github.com> | 2024-06-18 18:38:08 +0200 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-06-18 17:53:59 +0000 |
| commit | b8a592fe6e2d1b537b229625cd3d439a7d5a6eb5 (patch) | |
| tree | 30dfd0d5e64f75fbd27cfcedc953c23420a6d418 | |
| parent | 4b04da1ee81c460c591456d8d24792af55cd5c5f (diff) | |
[rubygems/rubygems] Fix `bundle fund` when the gemfile contains optional groups
`current_dependencies` doesn't return gems in optional groups, while `specs` would
Closes https://github.com/rubygems/rubygems/pull/7757
https://github.com/rubygems/rubygems/commit/c797e95636
| -rw-r--r-- | lib/bundler/cli/fund.rb | 2 | ||||
| -rw-r--r-- | spec/bundler/commands/fund_spec.rb | 36 |
2 files changed, 37 insertions, 1 deletions
diff --git a/lib/bundler/cli/fund.rb b/lib/bundler/cli/fund.rb index 52db5aef68..ad7f31f3d6 100644 --- a/lib/bundler/cli/fund.rb +++ b/lib/bundler/cli/fund.rb @@ -16,7 +16,7 @@ module Bundler deps = if groups.any? Bundler.definition.dependencies_for(groups) else - Bundler.definition.current_dependencies + Bundler.definition.requested_dependencies end fund_info = deps.each_with_object([]) do |dep, arr| diff --git a/spec/bundler/commands/fund_spec.rb b/spec/bundler/commands/fund_spec.rb index 5415b88eeb..cc32a7242f 100644 --- a/spec/bundler/commands/fund_spec.rb +++ b/spec/bundler/commands/fund_spec.rb @@ -55,6 +55,42 @@ RSpec.describe "bundle fund" do expect(out).to_not include("gem_with_dependent_funding") end + it "does not consider fund information for uninstalled optional dependencies" do + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + group :whatever, optional: true do + gem 'has_funding_and_other_metadata' + end + gem 'has_funding' + gem 'rack-obama' + G + + bundle "fund" + + expect(out).to include("* has_funding (1.2.3)\n Funding: https://example.com/has_funding/funding") + expect(out).to_not include("has_funding_and_other_metadata") + expect(out).to_not include("rack-obama") + end + + it "considers fund information for installed optional dependencies" do + bundle "config set with whatever" + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + group :whatever, optional: true do + gem 'has_funding_and_other_metadata' + end + gem 'has_funding' + gem 'rack-obama' + G + + bundle "fund" + + expect(out).to include("* has_funding_and_other_metadata (1.0)\n Funding: https://example.com/has_funding_and_other_metadata/funding") + expect(out).to include("* has_funding (1.2.3)\n Funding: https://example.com/has_funding/funding") + expect(out).to_not include("rack-obama") + end + it "prints message if none of the gems have fund information" do install_gemfile <<-G source "#{file_uri_for(gem_repo2)}" |
