Skip to content

Commit

Permalink
fix(bundler): Make parsing of dependency output more robust
Browse files Browse the repository at this point in the history
When fetching e.g. GitHub dependencies, the console output is slightly
different. Instead of adopting the lines to drop, suppress them
completely.

As now no leading text is printed, the concatenation of printed specs
can also be simplified so that it produces no leading null character.

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed May 15, 2024
1 parent 5e34581 commit 672b288
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ class Bundler(

// The metadata produced by the "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 {
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 @@ -33,9 +33,10 @@

# 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.
Bundler.definition.resolve_remotely!
puts Bundler.ui.silence {
Bundler.definition.resolve_remotely!

Bundler.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")
}

0 comments on commit 672b288

Please sign in to comment.