Skip to content

Commit

Permalink
Merge pull request #1448 from Shopify/ko/bundler-api
Browse files Browse the repository at this point in the history
Remove support for old Bundler API in materialize_deps
  • Loading branch information
KaanOzkan authored Mar 21, 2023
2 parents 31c852c + 74e06c8 commit 291c87c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 29 deletions.
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
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

0 comments on commit 291c87c

Please sign in to comment.