Skip to content

Commit f25e140

Browse files
committed
C#: Invert logic in HasPackageSource.
1 parent a92d37c commit f25e140

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetExeWrapper.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public NugetExeWrapper(FileProvider fileProvider, DependencyDirectory packageDir
4545
{
4646
logger.LogInfo($"Found packages.config files, trying to use nuget.exe for package restore");
4747
nugetExe = ResolveNugetExe();
48-
if (HasNoPackageSource() && useDefaultFeed())
48+
if (!HasPackageSource() && useDefaultFeed())
4949
{
5050
// We only modify or add a top level nuget.config file
5151
nugetConfigPath = Path.Combine(fileProvider.SourceDir.FullName, "nuget.config");
@@ -211,11 +211,11 @@ public int InstallPackages()
211211
return fileProvider.PackagesConfigs.Count(TryRestoreNugetPackage);
212212
}
213213

214-
private bool HasNoPackageSource()
214+
private bool HasPackageSource()
215215
{
216216
if (IsWindows)
217217
{
218-
return false;
218+
return true;
219219
}
220220

221221
try
@@ -224,15 +224,15 @@ private bool HasNoPackageSource()
224224
RunMonoNugetCommand("sources list -ForceEnglishOutput", out var stdout);
225225
if (stdout.All(line => line != "No sources found."))
226226
{
227-
return false;
227+
return true;
228228
}
229229

230-
return true;
230+
return false;
231231
}
232232
catch (Exception e)
233233
{
234234
logger.LogWarning($"Failed to check if default package source is added: {e}");
235-
return false;
235+
return true;
236236
}
237237
}
238238

0 commit comments

Comments
 (0)