Skip to content
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

Remove support for old Bundler API in materialize_deps #1448

Merged
merged 3 commits into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ PATH
remote: .
specs:
tapioca (0.11.2)
bundler (>= 1.17.3)
bundler (>= 2.2.25)
netrc (>= 0.11.0)
parallel (>= 1.21.0)
rbi (~> 0.0.0, >= 0.0.16)
Expand Down Expand Up @@ -392,4 +392,4 @@ DEPENDENCIES
xpath

BUNDLED WITH
2.3.26
2.4.9
15 changes: 7 additions & 8 deletions lib/tapioca/gemfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,13 @@ def load_dependencies
sig { returns([T::Enumerable[Spec], T::Array[String]]) }
def materialize_deps
deps = definition.locked_gems.dependencies.values
missing_specs = T::Array[String].new
materialized_dependencies = if definition.resolve.method(:materialize).arity == 1 # Support bundler >= v2.2.25
md = definition.resolve.materialize(deps)
missing_spec_names = md.missing_specs.map(&:name)
missing_specs = T.cast(md.missing_specs.map { |spec| "#{spec.name} (#{spec.version})" }, T::Array[String])
md.to_a.reject { |spec| missing_spec_names.include?(spec.name) }
else
definition.resolve.materialize(deps, missing_specs)
materialized_dependencies = definition.resolve.materialize(deps)
missing_spec_names = materialized_dependencies.missing_specs.map(&:name).to_set
missing_specs = materialized_dependencies.missing_specs.map do |spec|
"#{spec.name} (#{spec.version})"
end
materialized_dependencies = materialized_dependencies.to_a.reject do |spec|
missing_spec_names.include?(spec.name)
end
[materialized_dependencies, missing_specs]
end
Expand Down
19 changes: 1 addition & 18 deletions spec/tapioca/cli/gem_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ class Secret; end
end

it "must not include `rbi` definitions into `tapioca` RBI" do
@project.bundle_install
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were some flaky errors that made this test fail by processing ruby2_keywords so I added a bundle install call to ensure temporary project is in a good state before continuing.

result = @project.tapioca("gem tapioca")

assert_stdout_includes(result, <<~OUT)
Expand Down Expand Up @@ -689,24 +690,6 @@ class Secret; end
assert_success_status(result)
end

it "must not generate RBIs for missing gem specs on Bundler 2.2.22" do
@project.gemfile(<<~GEMFILE, append: true)
platform :rbx do
gem "ruby2_keywords", "0.0.5"
end
GEMFILE

@project.bundle_install(version: "2.2.22")

result = @project.tapioca("gem --all")

assert_stdout_includes(result, "completed with missing specs: ruby2_keywords (0.0.5)")
refute_includes(result.out, "Compiled ruby2_keywords")

# StdErr will have some messages about incompatibilities, so we don't check for clean err
assert_success_status(result)
end

it "must generate git gem RBIs with source revision numbers" do
@project.gemfile(<<~GEMFILE, append: true)
gem("faraday", git: "https://github.com/lostisland/faraday", ref: "23e249563613971ced8f851230c46b9eeeefe931")
Expand Down
2 changes: 1 addition & 1 deletion tapioca.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Gem::Specification.new do |spec|

spec.metadata["allowed_push_host"] = "https://rubygems.org"

spec.add_dependency("bundler", ">= 1.17.3")
spec.add_dependency("bundler", ">= 2.2.25")
spec.add_dependency("netrc", ">= 0.11.0")
spec.add_dependency("parallel", ">= 1.21.0")
spec.add_dependency("rbi", "~> 0.0.0", ">= 0.0.16")
Expand Down