Skip to content

Commit

Permalink
Merge pull request #10021 from dependabot/fix-docker-requirement-type
Browse files Browse the repository at this point in the history
Fix Docker Requirement initializer type
  • Loading branch information
landongrindheim committed Jun 17, 2024
2 parents 11ce6b8 + 6f82dc7 commit 29f2831
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docker/lib/dependabot/docker/requirement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ def satisfied_by?(version)

# Patches Gem::Requirement to make it accept requirement strings like
# "~> 4.2.5, >= 4.2.5.1" without first needing to split them.
sig { params(requirements: String).void }
sig { params(requirements: T.any(T.nilable(String), T::Array[T.nilable(String)])).void }
def initialize(*requirements)
requirements = requirements.flatten.flat_map do |req_string|
req_string.split(",").map(&:strip)
req_string.to_s.split(",").map(&:strip)
end

super(requirements)
Expand Down
6 changes: 6 additions & 0 deletions docker/spec/dependabot/docker/requirement_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@

it { is_expected.to eq(Gem::Requirement.new("> 20.8.1.alpine3.18", "< 20.9")) }
end

context "with a collection of strings" do
let(:requirement_string) { [">= 1.0.0", "< 2.0.0"] }

it { is_expected.to eq(Gem::Requirement.new(">= 1.0.0", "< 2.0.0")) }
end
end

describe "#satisfied_by?" do
Expand Down

0 comments on commit 29f2831

Please sign in to comment.