Class: Dependabot::Maven::FileParser::RepositoriesFinder
- Inherits:
-
Object
- Object
- Dependabot::Maven::FileParser::RepositoriesFinder
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/maven/file_parser/repositories_finder.rb
Constant Summary collapse
- REPOSITORY_SELECTOR =
"repositories > repository, " \ "pluginRepositories > pluginRepository"
Instance Method Summary collapse
- #central_repo_url ⇒ Object
-
#initialize(pom_fetcher:, dependency_files: [], credentials: [], evaluate_properties: true) ⇒ RepositoriesFinder
constructor
A new instance of RepositoriesFinder.
- #repository_urls(pom:, exclude_inherited: false, exclude_snapshots: true) ⇒ Object
Constructor Details
#initialize(pom_fetcher:, dependency_files: [], credentials: [], evaluate_properties: true) ⇒ RepositoriesFinder
Returns a new instance of RepositoriesFinder.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/dependabot/maven/file_parser/repositories_finder.rb', line 36 def initialize(pom_fetcher:, dependency_files: [], credentials: [], evaluate_properties: true) @pom_fetcher = pom_fetcher @dependency_files = dependency_files @credentials = credentials # We need the option not to evaluate properties so as not to have a # circular dependency between this class and the PropertyValueFinder # class @evaluate_properties = evaluate_properties # Aggregates URLs seen in POMs to avoid short term memory loss. # For instance a repository in a child POM might apply to the parent too. @known_urls = T.let([], T::Array[T::Hash[Symbol, T.untyped]]) @property_value_finder = T.let(nil, T.nilable(PropertyValueFinder)) end |
Instance Method Details
#central_repo_url ⇒ Object
52 53 54 55 |
# File 'lib/dependabot/maven/file_parser/repositories_finder.rb', line 52 def central_repo_url base = @credentials.find { |cred| cred["type"] == "maven_repository" && cred.replaces_base? } base ? T.must(base["url"]) : "https://repo.maven.apache.org/maven2" end |
#repository_urls(pom:, exclude_inherited: false, exclude_snapshots: true) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/dependabot/maven/file_parser/repositories_finder.rb', line 66 def repository_urls(pom:, exclude_inherited: false, exclude_snapshots: true) entries = gather_repository_urls(pom: pom, exclude_inherited: exclude_inherited) ids = Set.new @known_urls += entries.filter_map do |entry| next if entry[:id] && ids.include?(entry[:id]) ids.add(entry[:id]) unless entry[:id].nil? entry end @known_urls = @known_urls.uniq urls = urls_from_credentials + @known_urls.reject { |entry| exclude_snapshots && entry[:snapshots] } .map { |entry| entry[:url] } urls += [central_repo_url] unless @known_urls.any? { |entry| entry[:id] == super_pom[:id] } urls.uniq end |