-
Notifications
You must be signed in to change notification settings - Fork 162
feat: Show list of ignored gems #2354
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,7 +17,9 @@ def execute | |||||||||||||
| halt_upon_load_error: @halt_upon_load_error, | ||||||||||||||
| ) | ||||||||||||||
|
|
||||||||||||||
| gem_queue = gems_to_generate(@gem_names).reject { |gem| @exclude.include?(gem.name) } | ||||||||||||||
| gem_queue = gems_to_generate(@gem_names) | ||||||||||||||
| user_excluded_gems = user_excluded_gem_names(gem_queue) | ||||||||||||||
| gem_queue.reject! { |gem| @exclude.include?(gem.name) } | ||||||||||||||
| anything_done = [ | ||||||||||||||
| perform_removals, | ||||||||||||||
| gem_queue.any?, | ||||||||||||||
|
|
@@ -44,6 +46,14 @@ def execute | |||||||||||||
| else | ||||||||||||||
| say("No operations performed, all RBIs are up-to-date.", [:green, :bold]) | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be printed at the end, let's move the new prints before this if/else. |
||||||||||||||
| end | ||||||||||||||
| unless @skipped_gems.empty? | ||||||||||||||
| say("\nNote: Tapioca is skipping gem rbi generation for following gems due to the built-in configuration:", [:yellow, :bold]) | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| say(@skipped_gems.join(", "), [:yellow, :bold]) | ||||||||||||||
| end | ||||||||||||||
| unless user_excluded_gems.empty? | ||||||||||||||
| say("\nNote: Tapioca is skipping gem rbi generation for following gems due to user configuration:", [:yellow, :bold]) | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| say(user_excluded_gems.join(", "), [:yellow, :bold]) | ||||||||||||||
| end | ||||||||||||||
| ensure | ||||||||||||||
| GitAttributes.create_generated_attribute_file(@outpath) | ||||||||||||||
| end | ||||||||||||||
|
|
@@ -56,16 +66,28 @@ def gems_to_generate(gem_names) | |||||||||||||
| gem = @bundle.gem(gem_name) | ||||||||||||||
|
|
||||||||||||||
| if gem.nil? | ||||||||||||||
| next if @lsp_addon | ||||||||||||||
|
|
||||||||||||||
| raise Tapioca::Error, set_color("Error: Cannot find gem '#{gem_name}'", :red) | ||||||||||||||
| if @lsp_addon | ||||||||||||||
| next | ||||||||||||||
| elsif Gemfile::GemSpec::IGNORED_GEMS.include?(gem_name) | ||||||||||||||
| @skipped_gems << gem_name | ||||||||||||||
| next | ||||||||||||||
| else | ||||||||||||||
| raise Tapioca::Error, set_color("Error: Cannot find gem '#{gem_name}'", :red) | ||||||||||||||
| end | ||||||||||||||
| end | ||||||||||||||
|
|
||||||||||||||
| gems.concat(gem_dependencies(gem)) if @include_dependencies | ||||||||||||||
| gems << gem | ||||||||||||||
| end | ||||||||||||||
| end | ||||||||||||||
|
|
||||||||||||||
| #: (Array[Gemfile::GemSpec] gem_queue) -> Array[String] | ||||||||||||||
| def user_excluded_gem_names(gem_queue) | ||||||||||||||
| @exclude.uniq.select do |gem_name| | ||||||||||||||
| @bundle.gem(gem_name) && | ||||||||||||||
| (@gem_names.include?(gem_name) || gem_queue.any? { |gem| gem.name == gem_name }) | ||||||||||||||
| end | ||||||||||||||
| end | ||||||||||||||
|
Comment on lines
+84
to
+89
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
|
|
||||||||||||||
| #: (Gemfile::GemSpec gem, ?Array[Gemfile::GemSpec] dependencies) -> Array[Gemfile::GemSpec] | ||||||||||||||
| def gem_dependencies(gem, dependencies = []) | ||||||||||||||
| direct_dependencies = gem.dependencies.filter_map { |dependency| @bundle.gem(dependency.name) } | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -877,6 +877,49 @@ class Secret; end | |
| assert_success_status(result) | ||
| end | ||
|
|
||
| it "reports explicitly requested ignored gems" do | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also add a test for not reporting excluded gems when we only run |
||
| result = @project.tapioca("gem sorbet", exclude: []) | ||
|
|
||
| assert_stdout_includes(result, <<~OUT) | ||
| Note: Tapioca is skipping gem rbi generation for following gems due to the built-in configuration: | ||
| sorbet | ||
| OUT | ||
| refute_includes(result.out, "Compiled sorbet") | ||
|
|
||
| assert_empty_stderr(result) | ||
| assert_success_status(result) | ||
| end | ||
|
|
||
| it "reports gems excluded by built-in and user configuration" do | ||
| result = @project.tapioca("gem sorbet rbi --exclude rbi") | ||
|
|
||
| assert_stdout_includes(result, <<~OUT) | ||
| Note: Tapioca is skipping gem rbi generation for following gems due to the built-in configuration: | ||
| sorbet | ||
| OUT | ||
| assert_stdout_includes(result, <<~OUT) | ||
| Note: Tapioca is skipping gem rbi generation for following gems due to user configuration: | ||
| rbi | ||
| OUT | ||
| refute_includes(result.out, "Compiled rbi") | ||
|
|
||
| assert_empty_stderr(result) | ||
| assert_success_status(result) | ||
| end | ||
|
|
||
| it "reports gems excluded by user configuration" do | ||
| result = @project.tapioca("gem rbi --exclude rbi") | ||
|
|
||
| assert_stdout_includes(result, <<~OUT) | ||
| Note: Tapioca is skipping gem rbi generation for following gems due to user configuration: | ||
| rbi | ||
| OUT | ||
| refute_includes(result.out, "Compiled rbi") | ||
|
|
||
| assert_empty_stderr(result) | ||
| assert_success_status(result) | ||
| end | ||
|
|
||
| it "fails with error when gem cannot be found" do | ||
| result = @project.tapioca("gem non_existent_gem") | ||
|
|
||
|
|
||
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.
Simpler
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.
Also I think we should move
user_excluded_gemsassignment right before it's printed. It's nicer I believe.