Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions maven/lib/dependabot/maven/update_checker/version_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ def versions
version_details =
repositories.map do |repository_details|
url = repository_details.fetch("url")
dependency_metadata(repository_details).
css("versions > version").
xml = dependency_metadata(repository_details)
next [] unless xml
Comment thread
jakecoffman marked this conversation as resolved.
Outdated

break xml.css("versions > version").
select { |node| version_class.correct?(node.content) }.
map { |node| version_class.new(node.content) }.
map { |version| { version: version, source_url: url } }
Expand Down Expand Up @@ -166,15 +168,16 @@ def fetch_dependency_metadata(repository_details)
headers: repository_details.fetch("auth_headers")
)
check_response(response, repository_details.fetch("url"))
return unless response.status < 400

Nokogiri::XML(response.body)
rescue URI::InvalidURIError
Nokogiri::XML("")
nil
rescue Excon::Error::Socket, Excon::Error::Timeout,
Excon::Error::TooManyRedirects
raise if central_repo_urls.include?(repository_details["url"])

Nokogiri::XML("")
nil
end

def check_response(response, repository_url)
Expand Down
4 changes: 4 additions & 0 deletions maven/lib/dependabot/maven/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def initialize(version)
super(version.to_s.tr("_", "-"))
end

def inspect
"#<#{self.class} #{@version_string}>"
end

def to_s
@version_string
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -707,9 +707,12 @@
fixture("maven_central_metadata", "with_date_releases.xml")
stub_request(:get, maven_central_metadata_url).
to_return(status: 200, body: body)
# 404 causes Dependabot to fall back to the central repo
stub_request(:get, jboss_metadata_url).
to_return(status: 404)
end

its(:count) { is_expected.to eq(87) }
its(:count) { is_expected.to eq(17) }
Comment on lines -712 to +715

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤯


describe "the first version" do
subject { versions.first }
Expand Down