Class: Dependabot::Config::UpdateConfig
- Inherits:
-
Object
- Object
- Dependabot::Config::UpdateConfig
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/config/update_config.rb
Overview
Configuration for a single ecosystem
Defined Under Namespace
Classes: CommitMessageOptions
Instance Attribute Summary collapse
-
#commit_message_options ⇒ Object
readonly
Returns the value of attribute commit_message_options.
-
#exclude_paths ⇒ Object
readonly
Returns the value of attribute exclude_paths.
-
#ignore_conditions ⇒ Object
readonly
Returns the value of attribute ignore_conditions.
Class Method Summary collapse
Instance Method Summary collapse
- #extract_base_version_from_requirement(dependency) ⇒ Object
- #ignored_versions_for(dependency, security_updates_only: false) ⇒ Object
-
#initialize(ignore_conditions: nil, commit_message_options: nil, exclude_paths: nil) ⇒ UpdateConfig
constructor
A new instance of UpdateConfig.
Constructor Details
#initialize(ignore_conditions: nil, commit_message_options: nil, exclude_paths: nil) ⇒ UpdateConfig
29 30 31 32 33 |
# File 'lib/dependabot/config/update_config.rb', line 29 def initialize(ignore_conditions: nil, commit_message_options: nil, exclude_paths: nil) @ignore_conditions = T.let(ignore_conditions || [], T::Array[IgnoreCondition]) @commit_message_options = @exclude_paths = exclude_paths end |
Instance Attribute Details
#commit_message_options ⇒ Object (readonly)
Returns the value of attribute commit_message_options.
14 15 16 |
# File 'lib/dependabot/config/update_config.rb', line 14 def @commit_message_options end |
#exclude_paths ⇒ Object (readonly)
Returns the value of attribute exclude_paths.
20 21 22 |
# File 'lib/dependabot/config/update_config.rb', line 20 def exclude_paths @exclude_paths end |
#ignore_conditions ⇒ Object (readonly)
Returns the value of attribute ignore_conditions.
17 18 19 |
# File 'lib/dependabot/config/update_config.rb', line 17 def ignore_conditions @ignore_conditions end |
Class Method Details
.wildcard_match?(wildcard_string, candidate_string) ⇒ Boolean
66 67 68 69 70 71 72 73 74 |
# File 'lib/dependabot/config/update_config.rb', line 66 def self.wildcard_match?(wildcard_string, candidate_string) return false unless wildcard_string && candidate_string regex_string = "a#{wildcard_string.downcase}a".split("*") .map { |p| Regexp.quote(p) } .join(".*").gsub(/^a|a$/, "") regex = /^#{regex_string}$/ regex.match?(candidate_string.downcase) end |
Instance Method Details
#extract_base_version_from_requirement(dependency) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/dependabot/config/update_config.rb', line 53 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 |
#ignored_versions_for(dependency, security_updates_only: false) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/dependabot/config/update_config.rb', line 36 def ignored_versions_for(dependency, security_updates_only: false) normalizer = name_normaliser_for(dependency) dep_name = T.must(normalizer).call(dependency.name) if dependency.version.nil? && dependency.requirements.any? dependency = extract_base_version_from_requirement(dependency) end @ignore_conditions .select { |ic| self.class.wildcard_match?(T.must(normalizer).call(ic.dependency_name), dep_name) } .map { |ic| ic.ignored_versions(dependency, security_updates_only) } .flatten .compact .uniq end |