Skip to content

Commit

Permalink
(chocolatey#3461,chocolatey#3487) Address review comments
Browse files Browse the repository at this point in the history
Address review comments by using full version string for PackageResults,
and use case insensitive compares when determining if a package has
dependencies that failed to install.
  • Loading branch information
corbob committed Sep 23, 2024
1 parent 8841937 commit e5cd10a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/chocolatey/infrastructure.app/services/NugetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -801,13 +801,13 @@ Version was specified as '{0}'. It is possible that version
foreach (SourcePackageDependencyInfo packageDependencyInfo in resolvedPackages)
{
// Don't attempt to action this package if dependencies failed.
if (packageDependencyInfo != null && packageResultsToReturn.Any(r => r.Value.Success != true && packageDependencyInfo.Dependencies.Any(d => d.Id == r.Value.Identity.Id)))
if (packageDependencyInfo != null && packageResultsToReturn.Any(r => r.Value.Success != true && packageDependencyInfo.Dependencies.Any(d => d.Id.Equals(r.Value.Identity.Id, StringComparison.OrdinalIgnoreCase))))
{
var logMessage = StringResources.ErrorMessages.DependencyFailedToInstall.FormatWith(packageDependencyInfo.Id);
packageResultsToReturn
.GetOrAdd(
packageDependencyInfo.Id,
new PackageResult(packageDependencyInfo.Id, packageDependencyInfo.Version.ToStringSafe(), string.Empty)
new PackageResult(packageDependencyInfo.Id, packageDependencyInfo.Version.ToFullStringChecked(), string.Empty)
)
.Messages.Add(new ResultMessage(ResultType.Error, logMessage));
this.Log().Error(ChocolateyLoggers.Important, logMessage);
Expand Down Expand Up @@ -1609,12 +1609,12 @@ public virtual ConcurrentDictionary<string, PackageResult> Upgrade(ChocolateyCon
}

// Don't attempt to action this package if dependencies failed.
if (packageResultsToReturn.Any(r => r.Value.Success != true && packageDependencyInfo.Dependencies.Any(d => d.Id == r.Value.Identity.Id)))
if (packageResultsToReturn.Any(r => r.Value.Success != true && packageDependencyInfo.Dependencies.Any(d => d.Id.Equals(r.Value.Identity.Id, StringComparison.OrdinalIgnoreCase))))
{
var logMessage = StringResources.ErrorMessages.DependencyFailedToInstall.FormatWith(packageDependencyInfo.Id, packageDependencyInfo.Version);
packageResultsToReturn.GetOrAdd(
packageDependencyInfo.Id,
new PackageResult(packageDependencyInfo.Id, packageDependencyInfo.Version.ToStringSafe(), string.Empty)
new PackageResult(packageDependencyInfo.Id, packageDependencyInfo.Version.ToFullStringChecked(), string.Empty)
)
.Messages.Add(new ResultMessage(ResultType.Error, logMessage));
this.Log().Error(ChocolateyLoggers.Important, logMessage);
Expand Down

0 comments on commit e5cd10a

Please sign in to comment.