Skip to content

Commit

Permalink
(chocolatey#3112) Sort summary results alphabetically
Browse files Browse the repository at this point in the history
The summary outputted by Chocolatey CLI about installed,
upgrade or installed packages are listed in an unorder list of
package names.

This commit updates the report summary to ensure these are
reported in alphabetical order in each category.
  • Loading branch information
AdmiringWorm committed Apr 28, 2023
1 parent f6fba49 commit 34298b7
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ private void BuildInstallExample(string packageName, StringBuilder sb, string co

private int ReportActionSummary(ConcurrentDictionary<string, PackageResult> packageResults, string actionName)
{
var successes = packageResults.OrEmpty().Where(p => p.Value.Success && !p.Value.Inconclusive);
var successes = packageResults.OrEmpty().Where(p => p.Value.Success && !p.Value.Inconclusive).OrderBy(p => p.Value.Name);
var failures = packageResults.Count(p => !p.Value.Success);
var warnings = packageResults.Count(p => p.Value.Warning);
var rebootPackages = packageResults.Count(p => new[] { 1641, 3010 }.Contains(p.Value.ExitCode));
Expand Down Expand Up @@ -1117,7 +1117,7 @@ private int ReportActionSummary(ConcurrentDictionary<string, PackageResult> pack
{
this.Log().Info("");
this.Log().Warn("Warnings:");
foreach (var warning in packageResults.Where(p => p.Value.Warning).OrEmpty())
foreach (var warning in packageResults.Where(p => p.Value.Warning).OrderBy(p => p.Value.Name).OrEmpty())
{
var warningMessage = warning.Value.Messages.FirstOrDefault(m => m.MessageType == ResultType.Warn);
this.Log().Warn(" - {0}{1}".FormatWith(warning.Value.Name, warningMessage != null ? " - {0}".FormatWith(warningMessage.Message) : string.Empty));
Expand All @@ -1128,7 +1128,7 @@ private int ReportActionSummary(ConcurrentDictionary<string, PackageResult> pack
{
this.Log().Info("");
this.Log().Warn("Packages requiring reboot:");
foreach (var reboot in packageResults.Where(p => new[] { 1641, 3010 }.Contains(p.Value.ExitCode)).OrEmpty())
foreach (var reboot in packageResults.Where(p => new[] { 1641, 3010 }.Contains(p.Value.ExitCode)).OrderBy(p => p.Value.Name).OrEmpty())
{
this.Log().Warn(" - {0}{1}".FormatWith(reboot.Value.Name, reboot.Value.ExitCode != 0 ? " (exit code {0})".FormatWith(reboot.Value.ExitCode) : string.Empty));
}
Expand All @@ -1141,7 +1141,7 @@ The recent package changes indicate a reboot is necessary.
{
this.Log().Info("");
this.Log().Error("Failures");
foreach (var failure in packageResults.Where(p => !p.Value.Success).OrEmpty())
foreach (var failure in packageResults.Where(p => !p.Value.Success).OrderBy(p => p.Value.Name).OrEmpty())
{
var errorMessage = failure.Value.Messages.FirstOrDefault(m => m.MessageType == ResultType.Error);
this.Log().Error(
Expand Down

0 comments on commit 34298b7

Please sign in to comment.