-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--exclude
should also exclude transitive dependencies
#2096
base: main
Are you sure you want to change the base?
--exclude
should also exclude transitive dependencies
#2096
Conversation
I realize that a potential solution would be to add all of the transitive dependencies to the exclude list. But, this becomes impractical very quickly. For example, excluding the |
We should add a test to ensure that if two gems have the same transitive dependency, excluding one of them will not exclude the transitive dependency. For example:
I think the code is probably already handling that, but I don't know if we have a test for it. |
assert(Dir[path].any?) | ||
assert(@project.glob(path).any?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't doing what it was supposed to be doing.
21c24d8
to
d9bfbc4
Compare
d9bfbc4
to
47032ce
Compare
Thanks for the suggestion, @vinistock. I added a transitive dependency that is shared by an excluded gem and a gem that isn't excluded ( |
@@ -77,7 +77,7 @@ def initialize( | |||
def gems_to_generate(gem_names) | |||
return @bundle.dependencies if gem_names.empty? | |||
|
|||
gem_names.each_with_object([]) do |gem_name, gems| | |||
(gem_names - @exclude).each_with_object([]) do |gem_name, gems| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change preserves the existing behavior covered by this spec.
Without this change, invoking tapioca gem foo --exclude foo
would fail with this error, which actually seems like pretty reasonable behavior to me. I'm not sure why you'd specify the name of a gem that you're excluding.
Error: Cannot find gem 'foo'
Motivation
Given this gemfile:
The following configuration should not generate any RBI files, but it does.
This would generate RBI files for all of RSpec's transitive dependencies (e.g.
rspec-core
,rspec-support
,rspec-mocks
,rspec-expectations
,diff-lcs
).Implementation
I just dropped all of the excluded gems from
definition.locked_gems.dependencies
.I'm not sure if this is actually the right solution, because there's something going on with
BundlerExt::AutoRequireHook.override_require_false(exclude: @excluded_gems)
that I don't fully understand.Tests
I updated the existing CLI test for the
--exclude
option. I've also test this against a real project, and it seems to work.