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

Make parsing of Bundler dependency output more robust #8644

Merged
merged 4 commits into from
May 15, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ project:
- id: "Gem::rack:2.1.4"
- name: "test"
dependencies:
- id: "Gem::elasticsearch-rails:7.2.1"
- id: "Gem::rspec:3.7.0"
dependencies:
- id: "Gem::rspec-core:3.7.1"
Expand Down Expand Up @@ -78,6 +79,38 @@ packages:
url: "https://github.com/halostatue/diff-lcs.git"
revision: ""
path: ""
- id: "Gem::elasticsearch-rails:7.2.1"
purl: "pkg:gem/[email protected]"
authors:
- "Karel Minarik"
declared_licenses:
- "Apache 2"
declared_licenses_processed:
spdx_expression: "Apache-2.0"
mapped:
Apache 2: "Apache-2.0"
description: "Ruby on Rails integrations for Elasticsearch."
homepage_url: "https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/ruby_on_rails.html"
binary_artifact:
url: ""
hash:
value: ""
algorithm: ""
source_artifact:
url: "https://rubygems.org/gems/elasticsearch-rails-7.2.1.gem"
hash:
value: "0750dc0e956358d9a3a0912a8186c266ef19f8de0b178c61996ed1a6998156e4"
algorithm: "SHA-256"
vcs:
type: "Git"
url: "https://github.com/elastic/elasticsearch-rails.git"
revision: ""
path: ""
vcs_processed:
type: "Git"
url: "https://github.com/elastic/elasticsearch-rails.git"
revision: ""
path: ""
- id: "Gem::mini_portile2:2.4.0"
purl: "pkg:gem/[email protected]"
authors:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ gem 'rack', '~>2.1'

group :test do
gem 'rspec', :require => 'spec'
gem 'elasticsearch-rails', github: 'elastic/elasticsearch-rails', ref: 'v7.2.1'
end
6 changes: 3 additions & 3 deletions plugins/package-managers/bundler/src/main/kotlin/Bundler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ class Bundler(
private fun resolveGemsMetadata(workingDir: File): MutableMap<String, GemSpec> {
val stdout = runScriptResource(RESOLVE_DEPENDENCIES_SCRIPT, workingDir)

// The metadata produced by the "bundler_resolve_dependencies.rb" script separates specs for packages with the
// "\0" character as delimiter.
val gemSpecs = stdout.split('\u0000').dropWhile { it.startsWith("Fetching gem metadata") }.map {
// The metadata produced by the "resolve_dependencies.rb" script separates specs for packages with the "\0"
// character as delimiter.
val gemSpecs = stdout.split('\u0000').map {
GemSpec.createFromMetadata(yamlMapper.readTree(it))
}.associateByTo(mutableMapOf()) {
it.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@
# Resolve dependencies independently of the Ruby interpreter.
Bundler.settings.set_global(:force_ruby_platform, true)

definition = Bundler.definition

# This command tries to resolve dependencies that are specified in the Gemfile of the current working directory.
# Explicitly enable resolution of remote `gem` or `git` dependencies. `path` dependencies are still resolved locally.
definition.resolve_remotely!
puts Bundler.ui.silence {
Bundler.definition.resolve_remotely!

definition.specs.each do |spec|
puts("\0")
puts(spec.to_yaml)
end
# Resolving is triggered lazily, so the below "to_yaml" call might be the place where progress output needs to be
# silenced in addition to the above "resolve_remotely" call.
Bundler.definition.specs.map { |spec| spec.to_yaml }.join("\0")
}
Loading