Skip to content

Commit

Permalink
As per the review comment, extracted logic to new method.
Browse files Browse the repository at this point in the history
  • Loading branch information
“Thavachelvam committed Dec 20, 2024
1 parent 802826e commit a5ee962
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions common/lib/dependabot/config/update_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,8 @@ def ignored_versions_for(dependency, security_updates_only: false)
normalizer = name_normaliser_for(dependency)
dep_name = T.must(normalizer).call(dependency.name)

# When the version is not set, extract the base version from the requirement.
if dependency.version.nil? && dependency.requirements.any?
requirements = dependency.requirements
requirement = T.must(requirements.first)[:requirement]
version = requirement&.match(/\d+\.\d+\.\d+/)&.to_s
dependency = Dependabot::Dependency.new(
name: dependency.name,
version: version,
requirements: dependency.requirements,
package_manager: dependency.package_manager
)
dependency = extract_base_version_from_requirement(dependency)
end

@ignore_conditions
Expand All @@ -53,6 +44,19 @@ def ignored_versions_for(dependency, security_updates_only: false)
.uniq
end

sig { params(dependency: Dependency).returns(Dependency) }
def extract_base_version_from_requirement(dependency)
requirements = dependency.requirements
requirement = T.must(requirements.first)[:requirement]
version = requirement&.match(/\d+\.\d+\.\d+/)&.to_s
Dependabot::Dependency.new(
name: dependency.name,
version: version,
requirements: dependency.requirements,
package_manager: dependency.package_manager
)
end

sig { params(wildcard_string: T.nilable(String), candidate_string: T.nilable(String)).returns(T::Boolean) }
def self.wildcard_match?(wildcard_string, candidate_string)
return false unless wildcard_string && candidate_string
Expand Down

0 comments on commit a5ee962

Please sign in to comment.