From e8f477a63162bfcf5ad65d2e2155e5473b6e5370 Mon Sep 17 00:00:00 2001 From: Jake Coffman Date: Fri, 10 May 2024 11:19:24 -0500 Subject: [PATCH] fix exceptions from integration tests due to no metadata finders (#9697) --- .../metadata_finders/base/changelog_finder.rb | 1 + .../metadata_finders/base/commits_finder.rb | 1 + .../metadata_finders/base/release_finder.rb | 2 +- .../pull_request_creator/pr_name_prefixer.rb | 2 ++ silent/lib/dependabot/silent.rb | 4 ++- .../lib/dependabot/silent/metadata_finder.rb | 32 +++++++++++++++++++ 6 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 silent/lib/dependabot/silent/metadata_finder.rb diff --git a/common/lib/dependabot/metadata_finders/base/changelog_finder.rb b/common/lib/dependabot/metadata_finders/base/changelog_finder.rb index adb4a453999..4f015838d11 100644 --- a/common/lib/dependabot/metadata_finders/base/changelog_finder.rb +++ b/common/lib/dependabot/metadata_finders/base/changelog_finder.rb @@ -297,6 +297,7 @@ def fetch_dependency_file_list(ref) when "gitlab" then fetch_gitlab_file_list when "azure" then fetch_azure_file_list when "codecommit" then [] # TODO: Fetch Files from Codecommit + when "example" then [] else raise "Unexpected repo provider '#{T.must(source).provider}'" end end diff --git a/common/lib/dependabot/metadata_finders/base/commits_finder.rb b/common/lib/dependabot/metadata_finders/base/commits_finder.rb index a83ee77a7e5..9e0f358e624 100644 --- a/common/lib/dependabot/metadata_finders/base/commits_finder.rb +++ b/common/lib/dependabot/metadata_finders/base/commits_finder.rb @@ -51,6 +51,7 @@ def commits_url when "bitbucket" then bitbucket_compare_path(new_tag, previous_tag) when "gitlab" then gitlab_compare_path(new_tag, previous_tag) when "azure" then azure_compare_path(new_tag, previous_tag) + when "example" then "" else raise "Unexpected source provider '#{T.must(source).provider}'" end diff --git a/common/lib/dependabot/metadata_finders/base/release_finder.rb b/common/lib/dependabot/metadata_finders/base/release_finder.rb index 87b2678bba8..3e7a6b6d1d4 100644 --- a/common/lib/dependabot/metadata_finders/base/release_finder.rb +++ b/common/lib/dependabot/metadata_finders/base/release_finder.rb @@ -242,7 +242,7 @@ def fetch_dependency_releases when "github" then fetch_github_releases # Bitbucket and CodeCommit don't support releases and # Azure can't list API for annotated tags - when "bitbucket", "azure", "codecommit" then [] + when "bitbucket", "azure", "codecommit", "example" then [] when "gitlab" then fetch_gitlab_releases else raise "Unexpected repo provider '#{T.must(source).provider}'" end diff --git a/common/lib/dependabot/pull_request_creator/pr_name_prefixer.rb b/common/lib/dependabot/pull_request_creator/pr_name_prefixer.rb index 4c90fe78fad..af09474e5c7 100644 --- a/common/lib/dependabot/pull_request_creator/pr_name_prefixer.rb +++ b/common/lib/dependabot/pull_request_creator/pr_name_prefixer.rb @@ -317,6 +317,7 @@ def recent_commit_messages when "azure" then recent_azure_commit_messages when "bitbucket" then recent_bitbucket_commit_messages when "codecommit" then recent_codecommit_commit_messages + when "example" then [] else raise "Unsupported provider: #{source.provider}" end end @@ -402,6 +403,7 @@ def last_dependabot_commit_message when "azure" then last_azure_dependabot_commit_message when "bitbucket" then last_bitbucket_dependabot_commit_message when "codecommit" then last_codecommit_dependabot_commit_message + when "example" then nil else raise "Unsupported provider: #{source.provider}" end, T.nilable(String) diff --git a/silent/lib/dependabot/silent.rb b/silent/lib/dependabot/silent.rb index 1308bb39db7..b964680193e 100644 --- a/silent/lib/dependabot/silent.rb +++ b/silent/lib/dependabot/silent.rb @@ -7,7 +7,7 @@ require "dependabot/silent/file_parser" require "dependabot/silent/update_checker" require "dependabot/silent/file_updater" -# require "dependabot/silent/metadata_finder" TODO +require "dependabot/silent/metadata_finder" require "dependabot/silent/requirement" require "dependabot/silent/version" @@ -18,3 +18,5 @@ require "dependabot/dependency" Dependabot::Dependency .register_production_check("silent", ->(groups) { groups.empty? || groups.include?("prod") }) + +Dependabot::MetadataFinders.register("silent", Dependabot::Silent::MetadataFinder) diff --git a/silent/lib/dependabot/silent/metadata_finder.rb b/silent/lib/dependabot/silent/metadata_finder.rb new file mode 100644 index 00000000000..834c6e00da1 --- /dev/null +++ b/silent/lib/dependabot/silent/metadata_finder.rb @@ -0,0 +1,32 @@ +# typed: strong +# frozen_string_literal: true + +require "dependabot/metadata_finders" +require "dependabot/metadata_finders/base" + +module Dependabot + module Silent + class MetadataFinder < Dependabot::MetadataFinders::Base + extend T::Sig + + sig { returns(String) } + def homepage_url + "" + end + + private + + sig { override.returns(Dependabot::Source) } + def look_up_source + Dependabot::Source.new( + provider: "example", + hostname: "example.com", + api_endpoint: "https://example.com/api/v3", + repo: dependency.name, + directory: nil, + branch: nil + ) + end + end + end +end