Skip to content

Commit

Permalink
(chocolatey#2304) Fix list --exact -a for prereleases
Browse files Browse the repository at this point in the history
Due to a prior fix in the logic for `list -e -a`, all packages with the
target ID were being returned, regardless of whether the user uses the
`--pre` flag or not. Since the same search without `--exact` does not
return prerelease versions unless the `--pre` option is also passed, the
behaviour for `list -e -a` should match this.

This fix modifies the search logic used when listing all package
versions with `--exact` to also check for and respect the `--pre` flag
from the configuration context, much like other list commands use the
setting in this file in other places.
  • Loading branch information
vexx32 committed Aug 2, 2021
1 parent af3e8c9 commit 5be2fd4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/chocolatey/infrastructure.app/nuget/NugetList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ private static IQueryable<IPackage> execute_package_search(ChocolateyConfigurati
{
// 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);
results = packageRepository.GetPackages().Where(
p => p.Id.ToLower() == searchTermLower
&& (configuration.Prerelease || p.IsReleaseVersion()));
}
else
{
Expand Down

0 comments on commit 5be2fd4

Please sign in to comment.