Skip to content

Commit

Permalink
Use requirements_array for all ignore reqs
Browse files Browse the repository at this point in the history
  • Loading branch information
feelepxyz committed Apr 19, 2021
1 parent f7bc595 commit 9ffe120
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def dependency_source
end

def ignore_reqs
ignored_versions.map { |req| Gem::Requirement.new(req.split(",")) }
ignored_versions.flat_map { |req| requirement_class.requirements_array(req) }
end

def gemfile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def wants_prerelease?
end

def ignore_reqs
ignored_versions.map { |req| requirement_class.new(req.split(",")) }
ignored_versions.flat_map { |req| requirement_class.requirements_array(req) }
end

def version_class
Expand Down
2 changes: 1 addition & 1 deletion common/lib/dependabot/git_commit_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def listing_upload_pack
end

def ignore_reqs
ignored_versions.map { |req| requirement_class.new(req.split(",")) }
ignored_versions.flat_map { |req| requirement_class.requirements_array(req) }
end

def wants_prerelease?
Expand Down
4 changes: 1 addition & 3 deletions docker/lib/dependabot/docker/update_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,7 @@ def filter_ignored(candidate_tags)
end

def ignore_reqs
# NOTE: we use Gem::Requirement here because ignore conditions will
# be passed as Ruby ranges
ignored_versions.map { |req| Gem::Requirement.new(req.split(",")) }
ignored_versions.flat_map { |req| requirement_class.requirements_array(req) }
end
end
end
Expand Down
4 changes: 1 addition & 3 deletions elm/lib/dependabot/elm/update_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ def requirements_up_to_date?
end

def ignore_reqs
# NOTE: we use Gem::Requirement here because ignore conditions will
# be passed as Ruby ranges
ignored_versions.map { |req| Gem::Requirement.new(req.split(",")) }
ignored_versions.flat_map { |req| requirement_class.requirements_array(req) }
end
end
end
Expand Down
10 changes: 10 additions & 0 deletions hex/lib/dependabot/hex/requirement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ def self.requirements_array(requirement_string)
end
end

# Patches Gem::Requirement to make it accept requirement strings like
# "~> 4.2.5, >= 4.2.5.1" without first needing to split them.
def initialize(*requirements)
requirements = requirements.flatten.flat_map do |req_string|
req_string.split(",")
end

super(requirements)
end

# Override the parser to create Hex::Versions
def self.parse(obj)
return ["=", Hex::Version.new(obj.to_s)] if obj.is_a?(Gem::Version)
Expand Down
6 changes: 3 additions & 3 deletions npm_and_yarn/lib/dependabot/npm_and_yarn/requirement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def self.requirements_array(requirement_string)
end

def initialize(*requirements)
requirements = requirements.flatten.flat_map do |req_string|
convert_js_constraint_to_ruby_constraint(req_string)
end
requirements = requirements.flatten.
flat_map { |req_string| req_string.split(",") }.
flat_map { |req_string| convert_js_constraint_to_ruby_constraint(req_string) }

super(requirements)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def registry_finder
end

def ignore_reqs
ignored_versions.map { |req| requirement_class.new(req.split(",")) }
ignored_versions.flat_map { |req| requirement_class.requirements_array(req) }
end

def version_class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def registry_index_response(index_url)
end

def ignore_reqs
ignored_versions.map { |req| requirement_class.new(req.split(",")) }
ignored_versions.flat_map { |req| requirement_class.requirements_array(req) }
end

def normalised_name
Expand Down
10 changes: 10 additions & 0 deletions terraform/lib/dependabot/terraform/requirement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ def self.parse(obj)
def self.requirements_array(requirement_string)
[new(requirement_string)]
end

# Patches Gem::Requirement to make it accept requirement strings like
# "~> 4.2.5, >= 4.2.5.1" without first needing to split them.
def initialize(*requirements)
requirements = requirements.flatten.flat_map do |req_string|
req_string.split(",")
end

super(requirements)
end
end
end
end
Expand Down

0 comments on commit 9ffe120

Please sign in to comment.