From 56f1e9f03ca5c03426ea337cd86860777e60c0b2 Mon Sep 17 00:00:00 2001 From: Easton Pillay Date: Mon, 29 Nov 2021 13:44:54 -0500 Subject: [PATCH 01/10] Added --include-unknown command to `upgrade`. --- .../Commands/UpgradeCommand.cpp | 4 +- src/AppInstallerCLICore/ExecutionArgs.h | 1 + src/AppInstallerCLICore/Resources.h | 1 + .../Workflows/UpdateFlow.cpp | 75 ++++++++++++------- .../Workflows/WorkflowBase.cpp | 8 ++ .../Shared/Strings/en-us/winget.resw | 3 + 6 files changed, 62 insertions(+), 30 deletions(-) diff --git a/src/AppInstallerCLICore/Commands/UpgradeCommand.cpp b/src/AppInstallerCLICore/Commands/UpgradeCommand.cpp index 783cd32252..a2187b56f1 100644 --- a/src/AppInstallerCLICore/Commands/UpgradeCommand.cpp +++ b/src/AppInstallerCLICore/Commands/UpgradeCommand.cpp @@ -20,7 +20,8 @@ namespace AppInstaller::CLI bool ShouldListUpgrade(Context& context) { return context.Args.Empty() || - (context.Args.GetArgsCount() == 1 && context.Args.Contains(Execution::Args::Type::Source)); + (context.Args.GetArgsCount() == 1 && (context.Args.Contains(Execution::Args::Type::Source) || context.Args.Contains(Execution::Args::Type::IncludeUnknown))) || + (context.Args.GetArgsCount() == 2 && (context.Args.Contains(Execution::Args::Type::Source) && context.Args.Contains(Execution::Args::Type::IncludeUnknown))); } } @@ -46,6 +47,7 @@ namespace AppInstaller::CLI Argument::ForType(Args::Type::AcceptSourceAgreements), Argument::ForType(Execution::Args::Type::CustomHeader), Argument{ "all", Argument::NoAlias, Args::Type::All, Resource::String::UpdateAllArgumentDescription, ArgumentType::Flag }, + Argument{ "include-unknown", Argument::NoAlias, Args::Type::IncludeUnknown, Resource::String::IncludeUnknownArgumentDescription, ArgumentType::Flag } }; } diff --git a/src/AppInstallerCLICore/ExecutionArgs.h b/src/AppInstallerCLICore/ExecutionArgs.h index 5632992b75..3e7482a25f 100644 --- a/src/AppInstallerCLICore/ExecutionArgs.h +++ b/src/AppInstallerCLICore/ExecutionArgs.h @@ -85,6 +85,7 @@ namespace AppInstaller::CLI::Execution DependencySource, // Index source to be queried against for finding dependencies CustomHeader, // Optional Rest source header AcceptSourceAgreements, // Accept all source agreements + IncludeUnknown, // Used in Upgrade command to allow upgrades of packages with unknown versions // Used for demonstration purposes ExperimentalArg, diff --git a/src/AppInstallerCLICore/Resources.h b/src/AppInstallerCLICore/Resources.h index 09629e5437..05f451b8f3 100644 --- a/src/AppInstallerCLICore/Resources.h +++ b/src/AppInstallerCLICore/Resources.h @@ -104,6 +104,7 @@ namespace AppInstaller::CLI::Resource WINGET_DEFINE_RESOURCE_STRINGID(ImportPackageAlreadyInstalled); WINGET_DEFINE_RESOURCE_STRINGID(ImportSearchFailed); WINGET_DEFINE_RESOURCE_STRINGID(ImportSourceNotInstalled); + WINGET_DEFINE_RESOURCE_STRINGID(IncludeUnknownArgumentDescription); WINGET_DEFINE_RESOURCE_STRINGID(InstallAndUpgradeCommandsReportDependencies); WINGET_DEFINE_RESOURCE_STRINGID(InstallArchitectureArgumentDescription); WINGET_DEFINE_RESOURCE_STRINGID(InstallationAbandoned); diff --git a/src/AppInstallerCLICore/Workflows/UpdateFlow.cpp b/src/AppInstallerCLICore/Workflows/UpdateFlow.cpp index f1b18fe5da..b932e55e68 100644 --- a/src/AppInstallerCLICore/Workflows/UpdateFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/UpdateFlow.cpp @@ -44,46 +44,58 @@ namespace AppInstaller::CLI::Workflow bool updateFound = false; bool installedTypeInapplicable = false; - // The version keys should have already been sorted by version - const auto& versionKeys = package->GetAvailableVersionKeys(); - for (const auto& key : versionKeys) + if (!installedVersion.IsUnknown() || context.Args.Contains(Execution::Args::Type::IncludeUnknown)) { - // Check Update Version - if (IsUpdateVersionApplicable(installedVersion, Utility::Version(key.Version))) - { - auto packageVersion = package->GetAvailableVersion(key); - auto manifest = packageVersion->GetManifest(); - // Check applicable Installer - auto [installer, inapplicabilities] = manifestComparator.GetPreferredInstaller(manifest); - if (!installer.has_value()) + // The version keys should have already been sorted by version + const auto& versionKeys = package->GetAvailableVersionKeys(); + for (const auto& key : versionKeys) + { + // Check Update Version + if (IsUpdateVersionApplicable(installedVersion, Utility::Version(key.Version))) { - // If there is at least one installer whose only reason is InstalledType. - auto onlyInstalledType = std::find(inapplicabilities.begin(), inapplicabilities.end(), InapplicabilityFlags::InstalledType); - if (onlyInstalledType != inapplicabilities.end()) + auto packageVersion = package->GetAvailableVersion(key); + auto manifest = packageVersion->GetManifest(); + + // Check applicable Installer + auto [installer, inapplicabilities] = manifestComparator.GetPreferredInstaller(manifest); + if (!installer.has_value()) { - installedTypeInapplicable = true; + // If there is at least one installer whose only reason is InstalledType. + auto onlyInstalledType = std::find(inapplicabilities.begin(), inapplicabilities.end(), InapplicabilityFlags::InstalledType); + if (onlyInstalledType != inapplicabilities.end()) + { + installedTypeInapplicable = true; + } + + continue; } - continue; - } - - // Since we already did installer selection, just populate the context Data - manifest.ApplyLocale(installer->Locale); - context.Add(std::move(manifest)); - context.Add(std::move(packageVersion)); - context.Add(std::move(installer)); + // Since we already did installer selection, just populate the context Data + manifest.ApplyLocale(installer->Locale); + context.Add(std::move(manifest)); + context.Add(std::move(packageVersion)); + context.Add(std::move(installer)); - updateFound = true; - break; + updateFound = true; + break; + } + else + { + // Any following versions are not applicable + break; + } } - else + } + else + { + // the package has a unknown version and the user did not request to upgrade it anyway. + if (m_reportUpdateNotFound) { - // Any following versions are not applicable - break; + context.Reporter.Info() << Resource::String::UpdateNotApplicable << std::endl; } + AICLI_TERMINATE_CONTEXT(APPINSTALLER_CLI_ERROR_UPDATE_NOT_APPLICABLE); } - if (!updateFound) { if (m_reportUpdateNotFound) @@ -130,6 +142,11 @@ namespace AppInstaller::CLI::Workflow Execution::Context& updateContext = *updateContextPtr; updateContext.Add(match.Package); + + if (context.Args.Contains(Execution::Args::Type::IncludeUnknown)) + { + updateContext.Args.AddArg(Execution::Args::Type::IncludeUnknown); + } updateContext << Workflow::GetInstalledPackageVersion << diff --git a/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp b/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp index fe6d602d4e..e79ea08153 100644 --- a/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp +++ b/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp @@ -738,6 +738,14 @@ namespace AppInstaller::CLI::Workflow sourceName = latestVersion->GetProperty(PackageVersionProperty::SourceName); } + if (m_onlyShowUpgrades && !context.Args.Contains(Execution::Args::Type::IncludeUnknown) && Utility::Version(installedVersion->GetProperty(PackageVersionProperty::Version)).IsUnknown()) + { + // we are only supposed to be printing upgrades and the user did not request that packages with unknown versions be included + updateAvailable = false; + availableUpgradesCount--; + continue; + } + table.OutputLine({ match.Package->GetProperty(PackageProperty::Name), match.Package->GetProperty(PackageProperty::Id), diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw index 9600bf50eb..6dd637335b 100644 --- a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw +++ b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw @@ -1250,4 +1250,7 @@ Please specify one of them using the `--source` option to proceed. Select the architecture to install + + Upgrade packages even if their current version cannot be determined + \ No newline at end of file From eb3d2f0036d535459ece07cadbf7ab1ab662019c Mon Sep 17 00:00:00 2001 From: Easton Pillay Date: Thu, 2 Dec 2021 11:43:06 -0500 Subject: [PATCH 02/10] Added documentation of new arg, and moved if. --- doc/windows/package-manager/winget/upgrade.md | 10 +--------- src/AppInstallerCLICore/Workflows/WorkflowBase.cpp | 14 ++++++-------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/doc/windows/package-manager/winget/upgrade.md b/doc/windows/package-manager/winget/upgrade.md index afb54ee714..42acf7b7be 100644 --- a/doc/windows/package-manager/winget/upgrade.md +++ b/doc/windows/package-manager/winget/upgrade.md @@ -18,15 +18,6 @@ The **upgrade** command requires that you specify the exact string to upgrade. I ![upgrade command](images/upgrade.png) -## Arguments - -The following arguments are available. - -| Argument | Description | -|-------------|-------------| -| **-q,--query** | The query used to search for an app. | -| **-?, --help** | Get additional help on this command. | - ## Options The options allow you to customize the upgrade experience to meet your needs. @@ -47,6 +38,7 @@ The options allow you to customize the upgrade experience to meet your needs. | **-l, --location** | Location to upgrade to (if supported). | | **--force** | When a hash mismatch is discovered will ignore the error and attempt to install the package. | | **--all** | Updates all available packages to the latest application. | +| **--include-unknown** | Attempt to upgrade a package even if the package's current version is unknown. | ### Example queries The following example upgrades a specific version of an application. diff --git a/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp b/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp index 3aacd1fa3b..1aa7549755 100644 --- a/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp +++ b/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp @@ -720,6 +720,12 @@ namespace AppInstaller::CLI::Workflow auto latestVersion = match.Package->GetLatestAvailableVersion(); bool updateAvailable = match.Package->IsUpdateAvailable(); + if (m_onlyShowUpgrades && !context.Args.Contains(Execution::Args::Type::IncludeUnknown) && Utility::Version(installedVersion->GetProperty(PackageVersionProperty::Version)).IsUnknown()) + { + // We are only showing upgrades, and the user did not request to include packages with unknown versions. + continue; + } + // The only time we don't want to output a line is when filtering and no update is available. if (updateAvailable || !m_onlyShowUpgrades) { @@ -737,14 +743,6 @@ namespace AppInstaller::CLI::Workflow sourceName = latestVersion->GetProperty(PackageVersionProperty::SourceName); } - if (m_onlyShowUpgrades && !context.Args.Contains(Execution::Args::Type::IncludeUnknown) && Utility::Version(installedVersion->GetProperty(PackageVersionProperty::Version)).IsUnknown()) - { - // we are only supposed to be printing upgrades and the user did not request that packages with unknown versions be included - updateAvailable = false; - availableUpgradesCount--; - continue; - } - table.OutputLine({ match.Package->GetProperty(PackageProperty::Name), match.Package->GetProperty(PackageProperty::Id), From f80b3658d9a527742f00832e61e9a53a09945356 Mon Sep 17 00:00:00 2001 From: Easton Pillay Date: Thu, 2 Dec 2021 14:11:53 -0600 Subject: [PATCH 03/10] Fixed grammar for comment. --- src/AppInstallerCLICore/Workflows/UpdateFlow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AppInstallerCLICore/Workflows/UpdateFlow.cpp b/src/AppInstallerCLICore/Workflows/UpdateFlow.cpp index 43bbb976d5..f9d3465631 100644 --- a/src/AppInstallerCLICore/Workflows/UpdateFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/UpdateFlow.cpp @@ -101,7 +101,7 @@ namespace AppInstaller::CLI::Workflow } else { - // the package has a unknown version and the user did not request to upgrade it anyway. + // the package has an unknown version and the user did not request to upgrade it anyway. if (m_reportUpdateNotFound) { context.Reporter.Info() << Resource::String::UpdateNotApplicable << std::endl; @@ -187,4 +187,4 @@ namespace AppInstaller::CLI::Workflow APPINSTALLER_CLI_ERROR_UPDATE_ALL_HAS_FAILURE, { APPINSTALLER_CLI_ERROR_UPDATE_NOT_APPLICABLE }); } -} \ No newline at end of file +} From ae9ffc4206419ae3b13c2df680eb31219be48bf5 Mon Sep 17 00:00:00 2001 From: Easton Pillay Date: Thu, 2 Dec 2021 18:38:11 -0500 Subject: [PATCH 04/10] Added messaging/loop suggestions from code review. --- .../Commands/UpgradeCommand.cpp | 16 +++++++++++++--- src/AppInstallerCLICore/ExecutionArgs.h | 12 ++++++++++++ src/AppInstallerCLICore/Resources.h | 1 + src/AppInstallerCLICore/Workflows/UpdateFlow.cpp | 2 +- .../Shared/Strings/en-us/winget.resw | 3 +++ 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/AppInstallerCLICore/Commands/UpgradeCommand.cpp b/src/AppInstallerCLICore/Commands/UpgradeCommand.cpp index a2187b56f1..90c857201a 100644 --- a/src/AppInstallerCLICore/Commands/UpgradeCommand.cpp +++ b/src/AppInstallerCLICore/Commands/UpgradeCommand.cpp @@ -19,9 +19,19 @@ namespace AppInstaller::CLI { bool ShouldListUpgrade(Context& context) { - return context.Args.Empty() || - (context.Args.GetArgsCount() == 1 && (context.Args.Contains(Execution::Args::Type::Source) || context.Args.Contains(Execution::Args::Type::IncludeUnknown))) || - (context.Args.GetArgsCount() == 2 && (context.Args.Contains(Execution::Args::Type::Source) && context.Args.Contains(Execution::Args::Type::IncludeUnknown))); + if (!context.Args.Empty()) + { + for (Execution::Args::Type type : context.Args.GetTypes()) + { + if (type != Execution::Args::Type::Source && type != Execution::Args::Type::IncludeUnknown) + { + return false; + } + } + return true; + } + + return true; } } diff --git a/src/AppInstallerCLICore/ExecutionArgs.h b/src/AppInstallerCLICore/ExecutionArgs.h index 3e7482a25f..f5d231c6af 100644 --- a/src/AppInstallerCLICore/ExecutionArgs.h +++ b/src/AppInstallerCLICore/ExecutionArgs.h @@ -142,6 +142,18 @@ namespace AppInstaller::CLI::Execution return m_parsedArgs.size(); } + std::vector GetTypes() + { + std::vector types; + + for (auto const& i : m_parsedArgs) + { + types.emplace_back(i.first); + } + + return types; + } + private: std::map> m_parsedArgs; }; diff --git a/src/AppInstallerCLICore/Resources.h b/src/AppInstallerCLICore/Resources.h index 05f451b8f3..19e991868a 100644 --- a/src/AppInstallerCLICore/Resources.h +++ b/src/AppInstallerCLICore/Resources.h @@ -341,6 +341,7 @@ namespace AppInstaller::CLI::Resource WINGET_DEFINE_RESOURCE_STRINGID(UpgradeCommandShortDescription); WINGET_DEFINE_RESOURCE_STRINGID(UpgradeDifferentInstallTechnology); WINGET_DEFINE_RESOURCE_STRINGID(UpgradeDifferentInstallTechnologyInNewerVersions); + WINGET_DEFINE_RESOURCE_STRINGID(UpgradeUnknownVersionExplanation); WINGET_DEFINE_RESOURCE_STRINGID(Usage); WINGET_DEFINE_RESOURCE_STRINGID(ValidateCommandLongDescription); WINGET_DEFINE_RESOURCE_STRINGID(ValidateCommandReportDependencies); diff --git a/src/AppInstallerCLICore/Workflows/UpdateFlow.cpp b/src/AppInstallerCLICore/Workflows/UpdateFlow.cpp index 43bbb976d5..dd17c1ed63 100644 --- a/src/AppInstallerCLICore/Workflows/UpdateFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/UpdateFlow.cpp @@ -104,7 +104,7 @@ namespace AppInstaller::CLI::Workflow // the package has a unknown version and the user did not request to upgrade it anyway. if (m_reportUpdateNotFound) { - context.Reporter.Info() << Resource::String::UpdateNotApplicable << std::endl; + context.Reporter.Info() << Resource::String::UpgradeUnknownVersionExplanation << std::endl; } AICLI_TERMINATE_CONTEXT(APPINSTALLER_CLI_ERROR_UPDATE_NOT_APPLICABLE); } diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw index 6dd637335b..98b51e46fc 100644 --- a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw +++ b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw @@ -1253,4 +1253,7 @@ Please specify one of them using the `--source` option to proceed. Upgrade packages even if their current version cannot be determined + + This package's version number cannot be determined. To upgrade it anyway, add the argument --include-unknown to your previous command. + \ No newline at end of file From 488f8103aa7bb1cc25badf07a9d3e90edfa248e3 Mon Sep 17 00:00:00 2001 From: Easton Pillay Date: Thu, 2 Dec 2021 17:45:42 -0600 Subject: [PATCH 05/10] Apply suggestions from code review (localization) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Chacón --- src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw | 1 + 1 file changed, 1 insertion(+) diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw index 98b51e46fc..de8a5e8ae9 100644 --- a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw +++ b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw @@ -1255,5 +1255,6 @@ Please specify one of them using the `--source` option to proceed. This package's version number cannot be determined. To upgrade it anyway, add the argument --include-unknown to your previous command. + {Locked="--include-unknown"} \ No newline at end of file From 825dac312cd5f2c01067f4afa393bff3582a44e0 Mon Sep 17 00:00:00 2001 From: Easton Pillay Date: Fri, 3 Dec 2021 11:15:13 -0500 Subject: [PATCH 06/10] Added count of unknown packages. --- src/AppInstallerCLICore/AppInstallerCLICore.vcxproj | 1 + src/AppInstallerCLICore/Resources.h | 2 ++ src/AppInstallerCLICore/Workflows/WorkflowBase.cpp | 6 ++++++ .../Shared/Strings/en-us/winget.resw | 8 ++++++++ 4 files changed, 17 insertions(+) diff --git a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj index 50b644faca..b93e696e0c 100644 --- a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj +++ b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj @@ -174,6 +174,7 @@ true true true + true false diff --git a/src/AppInstallerCLICore/Resources.h b/src/AppInstallerCLICore/Resources.h index 19e991868a..5f5af6ce33 100644 --- a/src/AppInstallerCLICore/Resources.h +++ b/src/AppInstallerCLICore/Resources.h @@ -341,6 +341,8 @@ namespace AppInstaller::CLI::Resource WINGET_DEFINE_RESOURCE_STRINGID(UpgradeCommandShortDescription); WINGET_DEFINE_RESOURCE_STRINGID(UpgradeDifferentInstallTechnology); WINGET_DEFINE_RESOURCE_STRINGID(UpgradeDifferentInstallTechnologyInNewerVersions); + WINGET_DEFINE_RESOURCE_STRINGID(UpgradeUnknownCount); + WINGET_DEFINE_RESOURCE_STRINGID(UpgradeUnknownCountSingle); WINGET_DEFINE_RESOURCE_STRINGID(UpgradeUnknownVersionExplanation); WINGET_DEFINE_RESOURCE_STRINGID(Usage); WINGET_DEFINE_RESOURCE_STRINGID(ValidateCommandLongDescription); diff --git a/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp b/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp index 1aa7549755..56c18c569c 100644 --- a/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp +++ b/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp @@ -708,6 +708,7 @@ namespace AppInstaller::CLI::Workflow }); int availableUpgradesCount = 0; + int unknownPackagesCount = 0; auto &source = context.Get(); bool shouldShowSource = source.IsComposite() && source.GetAvailableSources().size() > 1; @@ -723,6 +724,7 @@ namespace AppInstaller::CLI::Workflow if (m_onlyShowUpgrades && !context.Args.Contains(Execution::Args::Type::IncludeUnknown) && Utility::Version(installedVersion->GetProperty(PackageVersionProperty::Version)).IsUnknown()) { // We are only showing upgrades, and the user did not request to include packages with unknown versions. + unknownPackagesCount++; continue; } @@ -772,6 +774,10 @@ namespace AppInstaller::CLI::Workflow context.Reporter.Info() << availableUpgradesCount << ' ' << Resource::String::AvailableUpgrades << std::endl; } } + if (m_onlyShowUpgrades && unknownPackagesCount > 0 && !context.Args.Contains(Execution::Args::Type::IncludeUnknown)) + { + context.Reporter.Info() << unknownPackagesCount << " " << (unknownPackagesCount == 1 ? Resource::String::UpgradeUnknownCountSingle : Resource::String::UpgradeUnknownCount) << std::endl; + } } diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw index de8a5e8ae9..e36e40b7ea 100644 --- a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw +++ b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw @@ -1257,4 +1257,12 @@ Please specify one of them using the `--source` option to proceed. This package's version number cannot be determined. To upgrade it anyway, add the argument --include-unknown to your previous command. {Locked="--include-unknown"} + + package's version numbers cannot be determined. Use "--include-unknown" to see all results. + {Locked="--include-unknown"} + + + package's version number cannot be determined. Use "--include-unknown" to see all results. + {Locked="--include-unknown"} + \ No newline at end of file From ebd54f9b378c9771f5ccd99c5ab6fa9607f9d094 Mon Sep 17 00:00:00 2001 From: Easton Pillay Date: Fri, 3 Dec 2021 12:44:22 -0500 Subject: [PATCH 07/10] Added count to upgrade --all too. --- .../Workflows/UpdateFlow.cpp | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/AppInstallerCLICore/Workflows/UpdateFlow.cpp b/src/AppInstallerCLICore/Workflows/UpdateFlow.cpp index aee5fefbf5..861d97f42c 100644 --- a/src/AppInstallerCLICore/Workflows/UpdateFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/UpdateFlow.cpp @@ -46,7 +46,6 @@ namespace AppInstaller::CLI::Workflow if (!installedVersion.IsUnknown() || context.Args.Contains(Execution::Args::Type::IncludeUnknown)) { - // The version keys should have already been sorted by version const auto& versionKeys = package->GetAvailableVersionKeys(); for (const auto& key : versionKeys) @@ -144,6 +143,7 @@ namespace AppInstaller::CLI::Workflow const auto& matches = context.Get().Matches; std::vector> packagesToInstall; bool updateAllFoundUpdate = false; + int unknownPackagesCount = 0; for (const auto& match : matches) { @@ -151,6 +151,7 @@ namespace AppInstaller::CLI::Workflow auto updateContextPtr = context.CreateSubContext(); Execution::Context& updateContext = *updateContextPtr; auto previousThreadGlobals = updateContext.SetForCurrentThread(); + auto installedVersion = match.Package->GetInstalledVersion(); updateContext.Add(match.Package); @@ -158,6 +159,12 @@ namespace AppInstaller::CLI::Workflow { updateContext.Args.AddArg(Execution::Args::Type::IncludeUnknown); } + else if (Utility::Version(installedVersion->GetProperty(PackageVersionProperty::Version)).IsUnknown()) + { + // we don't know what the package's version is and the user didn't ask to upgrade it anyway. + unknownPackagesCount++; + continue; + } updateContext << Workflow::GetInstalledPackageVersion << @@ -177,14 +184,19 @@ namespace AppInstaller::CLI::Workflow if (!updateAllFoundUpdate) { context.Reporter.Info() << Resource::String::UpdateNotApplicable << std::endl; - return; } - - context.Add(std::move(packagesToInstall)); - context << - InstallMultiplePackages( - Resource::String::InstallAndUpgradeCommandsReportDependencies, - APPINSTALLER_CLI_ERROR_UPDATE_ALL_HAS_FAILURE, - { APPINSTALLER_CLI_ERROR_UPDATE_NOT_APPLICABLE }); + else + { + context.Add(std::move(packagesToInstall)); + context << + InstallMultiplePackages( + Resource::String::InstallAndUpgradeCommandsReportDependencies, + APPINSTALLER_CLI_ERROR_UPDATE_ALL_HAS_FAILURE, + { APPINSTALLER_CLI_ERROR_UPDATE_NOT_APPLICABLE }); + } + if (unknownPackagesCount > 0 && !context.Args.Contains(Execution::Args::Type::IncludeUnknown)) + { + context.Reporter.Info() << unknownPackagesCount << " " << (unknownPackagesCount == 1 ? Resource::String::UpgradeUnknownCountSingle : Resource::String::UpgradeUnknownCount) << std::endl; + } } } From 841e76957df7520dcdff7b88f2503d0db7d3f987 Mon Sep 17 00:00:00 2001 From: Easton Pillay Date: Fri, 3 Dec 2021 15:44:58 -0500 Subject: [PATCH 08/10] Attempted to fix comments/phrasing for localization. --- .../Shared/Strings/en-us/winget.resw | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw index e36e40b7ea..bdc7b6b6d7 100644 --- a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw +++ b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw @@ -1258,11 +1258,11 @@ Please specify one of them using the `--source` option to proceed. {Locked="--include-unknown"} - package's version numbers cannot be determined. Use "--include-unknown" to see all results. - {Locked="--include-unknown"} + packages have version numbers that cannot be determined. Use "--include-unknown" to see all results. + {Locked="--include-unknown"} This string is preceded by a (integer) number of packages that do not have notated versions. - package's version number cannot be determined. Use "--include-unknown" to see all results. - {Locked="--include-unknown"} + package has a version number that cannot be determined. Use "--include-unknown" to see all results. + {Locked="--include-unknown"} This string is preceded by a (integer) number of packages that do not have notated versions. \ No newline at end of file From 6dc0982efb86691cf00efed52f62419d0e1cab2c Mon Sep 17 00:00:00 2001 From: Easton Pillay Date: Tue, 7 Dec 2021 10:57:41 -0500 Subject: [PATCH 09/10] Undid change to AppInstallerCLICore project -- sorry! --- src/AppInstallerCLICore/AppInstallerCLICore.vcxproj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj index b93e696e0c..50b644faca 100644 --- a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj +++ b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj @@ -174,7 +174,6 @@ true true true - true false From 2d49a69ff5905f18c0386431c0e22b3ae2030136 Mon Sep 17 00:00:00 2001 From: Easton Pillay Date: Thu, 9 Dec 2021 09:19:42 -0500 Subject: [PATCH 10/10] Removed unnecessary if statement for ShouldListUpgrade. --- src/AppInstallerCLICore/Commands/UpgradeCommand.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/AppInstallerCLICore/Commands/UpgradeCommand.cpp b/src/AppInstallerCLICore/Commands/UpgradeCommand.cpp index 90c857201a..9a0b182690 100644 --- a/src/AppInstallerCLICore/Commands/UpgradeCommand.cpp +++ b/src/AppInstallerCLICore/Commands/UpgradeCommand.cpp @@ -19,18 +19,13 @@ namespace AppInstaller::CLI { bool ShouldListUpgrade(Context& context) { - if (!context.Args.Empty()) + for (Execution::Args::Type type : context.Args.GetTypes()) { - for (Execution::Args::Type type : context.Args.GetTypes()) + if (type != Execution::Args::Type::Source && type != Execution::Args::Type::IncludeUnknown) { - if (type != Execution::Args::Type::Source && type != Execution::Args::Type::IncludeUnknown) - { - return false; - } + return false; } - return true; } - return true; } }