From 1f0b866d4673f1523a100cb8fc88130b29779372 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Mon, 6 Apr 2020 12:06:36 -0500 Subject: [PATCH] (GH-1843) Fix: search exact all versions returns 1 Previously, choco 0.10.15 switched to a new method of finding an exact package based on the name, however that change also meant it would only retrieve one version of a package. There is however a scenario of using the `--exact` switch to retrieve all available versions of a package. This method was used in some integration tools. The change put in for 0.10.15 broke this scenario completely. Check for all versions and return all packages for an exact search along with other search criteria. If not returning all versions, continue to use the updated method of retrieving a package. --- .../infrastructure.app/nuget/NugetList.cs | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/chocolatey/infrastructure.app/nuget/NugetList.cs b/src/chocolatey/infrastructure.app/nuget/NugetList.cs index 2d6a443d2b..1ab88c182f 100644 --- a/src/chocolatey/infrastructure.app/nuget/NugetList.cs +++ b/src/chocolatey/infrastructure.app/nuget/NugetList.cs @@ -65,14 +65,23 @@ private static IQueryable execute_package_search(ChocolateyConfigurati if (configuration.ListCommand.Exact) { - var exactPackage = find_package(searchTermLower, version, configuration, packageRepository); + if (configuration.AllVersions) + { + // convert from a search to getting packages by id. + // search based on lower case id - similar to PackageRepositoryExtensions.FindPackagesByIdCore() + results = packageRepository.GetPackages().Where(x => x.Id.ToLower() == searchTermLower); + } + else + { + var exactPackage = find_package(searchTermLower, version, configuration, packageRepository); - if (exactPackage == null) return new List().AsQueryable(); + if (exactPackage == null) return new List().AsQueryable(); - return new List() - { - exactPackage - }.AsQueryable(); + return new List() + { + exactPackage + }.AsQueryable(); + } } if (configuration.ListCommand.Page.HasValue)