Class: Dependabot::Config::UpdateConfig

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ignore_conditions: nil, commit_message_options: nil) ⇒ UpdateConfig

Returns a new instance of UpdateConfig.



25
26
27
28
# File 'lib/dependabot/config/update_config.rb', line 25

def initialize(ignore_conditions: nil, commit_message_options: nil)
  @ignore_conditions = T.let(ignore_conditions || [], T::Array[IgnoreCondition])
  @commit_message_options = commit_message_options
end

Instance Attribute Details

#commit_message_optionsObject (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
  @commit_message_options
end

#ignore_conditionsObject (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

Returns:

  • (Boolean)


44
45
46
47
48
49
50
51
52
# File 'lib/dependabot/config/update_config.rb', line 44

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

#ignored_versions_for(dependency, security_updates_only: false) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/dependabot/config/update_config.rb', line 31

def ignored_versions_for(dependency, security_updates_only: false)
  normalizer = name_normaliser_for(dependency)
  dep_name = T.must(normalizer).call(dependency.name)

  @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