Skip to content

Commit

Permalink
Changed version logic; exact behavior; and attached all results to va…
Browse files Browse the repository at this point in the history
…gue criteria error.
  • Loading branch information
jontab committed Jul 12, 2022
1 parent 5400885 commit 7f46ed1
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private string QueryAsJoinedString
protected virtual PackageFieldMatchOption GetExactAsMatchOption()
{
return this.Exact.ToBool()
? PackageFieldMatchOption.EqualsCaseInsensitive
? PackageFieldMatchOption.Equals
: PackageFieldMatchOption.ContainsCaseInsensitive;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ namespace Microsoft.WinGet.Client.Commands
using System;
using System.IO;
using System.Management.Automation;
using System.Reflection;
using System.Resources;
using Microsoft.Management.Deployment;
using Microsoft.WinGet.Client.Errors;
using Microsoft.WinGet.Client.Helpers;
Expand Down Expand Up @@ -57,6 +55,14 @@ public string Log
}
}

/// <inheritdoc />
protected override PackageFieldMatchOption GetExactAsMatchOption()
{
return this.Exact.ToBool()
? PackageFieldMatchOption.Equals
: PackageFieldMatchOption.EqualsCaseInsensitive;
}

/// <summary>
/// Executes a command targeting a specific package version.
/// </summary>
Expand All @@ -83,7 +89,7 @@ private CatalogPackage GetCatalogPackage(CompositeSearchBehavior behavior)
}
else
{
var results = this.FindPackages(behavior, 2);
var results = this.FindPackages(behavior, 0);
if (results.Count == 1)
{
return results[0].CatalogPackage;
Expand All @@ -107,18 +113,13 @@ private PackageVersionId GetPackageVersionId(CatalogPackage package)

for (var i = 0; i < versions.Count; i++)
{
// PackageVersionInfo.DisplayName (?)
bool match = this.Version.Equals(
versions[i].Version,
StringComparison.OrdinalIgnoreCase);

if (match)
if (versions[i].Version.CompareTo(this.Version) == 0)
{
return versions[i];
}
}

throw new ArgumentException("No version found matching: " + this.Version);
throw new ArgumentException(Constants.ResourceManager.GetString("ExceptionMessages_VersionNotFound"));
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace Microsoft.WinGet.Client.Commands
{
using System;
using System.Management.Automation;
using Microsoft.Management.Deployment;
using Microsoft.WinGet.Client.Helpers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

namespace Microsoft.WinGet.Client.Commands
{
using System;
using System.Management.Automation;
using Microsoft.Management.Deployment;
using Microsoft.WinGet.Client.Helpers;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,7 @@
<data name="ExceptionMessages_VagueSearch" xml:space="preserve">
<value>'{0}', '{1}', and {2} other package(s) matched the input criteria. Please refine the input.</value>
</data>
<data name="ExceptionMessages_VersionNotFound" xml:space="preserve">
<value>No version matched the given input criteria.</value>
</data>
</root>

0 comments on commit 7f46ed1

Please sign in to comment.