Skip to content

Commit

Permalink
(GH-1843) Fix: search exact all versions returns 1
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ferventcoder committed Apr 6, 2020
1 parent 9749861 commit 1f0b866
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/chocolatey/infrastructure.app/nuget/NugetList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,23 @@ private static IQueryable<IPackage> 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<IPackage>().AsQueryable();
if (exactPackage == null) return new List<IPackage>().AsQueryable();

return new List<IPackage>()
{
exactPackage
}.AsQueryable();
return new List<IPackage>()
{
exactPackage
}.AsQueryable();
}
}

if (configuration.ListCommand.Page.HasValue)
Expand Down

0 comments on commit 1f0b866

Please sign in to comment.