Skip to content

Commit 5db2b11

Browse files
authored
Merge pull request #5948 from dependabot/honeyankit/nuget-fix-public-registy-call
No public url call when public registry is disabled
2 parents a145284 + 76cf547 commit 5db2b11

File tree

2 files changed

+3
-32
lines changed

2 files changed

+3
-32
lines changed

nuget/lib/dependabot/nuget/metadata_finder.rb

+1-15
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,7 @@ def dependency_nuspec_url
121121
source = dependency.requirements.
122122
find { |r| r&.fetch(:source) }&.fetch(:source)
123123

124-
if source&.key?(:nuspec_url)
125-
source.fetch(:nuspec_url) ||
126-
"https://api.nuget.org/v3-flatcontainer/" \
127-
"#{dependency.name.downcase}/#{dependency.version}/" \
128-
"#{dependency.name.downcase}.nuspec"
129-
elsif source&.key?(:nuspec_url)
130-
source.fetch("nuspec_url") ||
131-
"https://api.nuget.org/v3-flatcontainer/" \
132-
"#{dependency.name.downcase}/#{dependency.version}/" \
133-
"#{dependency.name.downcase}.nuspec"
134-
else
135-
"https://api.nuget.org/v3-flatcontainer/" \
136-
"#{dependency.name.downcase}/#{dependency.version}/" \
137-
"#{dependency.name.downcase}.nuspec"
138-
end
124+
return source.fetch(:nuspec_url) if source&.key?(:nuspec_url)
139125
end
140126

141127
def dependency_source_url

nuget/spec/dependabot/nuget/metadata_finder_spec.rb

+2-17
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,6 @@
5959
)
6060
end
6161

62-
context "with a github link in the nuspec" do
63-
it { is_expected.to eq("https://github.com/dotnet/core-setup") }
64-
65-
it "caches the call to nuget" do
66-
2.times { source_url }
67-
expect(WebMock).to have_requested(:get, nuget_url).once
68-
end
69-
end
70-
7162
context "with a source" do
7263
let(:source) do
7364
{
@@ -94,7 +85,7 @@
9485
expect(WebMock).to have_requested(:get, nuget_url).once
9586
end
9687

97-
context "that has a source_url" do
88+
context "that has a source_url only" do
9889
let(:source) do
9990
{
10091
type: "nuget_repo",
@@ -117,13 +108,7 @@
117108
}
118109
end
119110

120-
let(:nuget_url) do
121-
"https://api.nuget.org/v3-flatcontainer/" \
122-
"microsoft.extensions.dependencymodel/2.1.0/" \
123-
"microsoft.extensions.dependencymodel.nuspec"
124-
end
125-
126-
it { is_expected.to eq("https://github.com/dotnet/core-setup") }
111+
it { is_expected.to eq(nil) }
127112
end
128113

129114
context "with details in the credentials (but no token)" do

0 commit comments

Comments
 (0)