Skip to content

Commit

Permalink
(chocolateyGH-1398) Use feature for ignore unfound pkgs
Browse files Browse the repository at this point in the history
Use a feature flip for ignoring unfound packages for outdated.
  • Loading branch information
ferventcoder committed Sep 14, 2017
1 parent 03ead14 commit 011ef6a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/chocolatey/infrastructure.app/ApplicationParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ public static class Features
public static readonly string ShowDownloadProgress = "showDownloadProgress";
public static readonly string StopOnFirstPackageFailure = "stopOnFirstPackageFailure";
public static readonly string UseRememberedArgumentsForUpgrades = "useRememberedArgumentsForUpgrades";
public static readonly string IgnoreUnfoundPackagesOnUpgradeOutdated = "ignoreUnfoundPackagesOnUpgradeOutdated";
}

public static class Messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,9 @@ private static void set_feature_flags(ChocolateyConfiguration config, ConfigFile
config.Features.UseFipsCompliantChecksums = set_feature_flag(ApplicationParameters.Features.UseFipsCompliantChecksums, configFileSettings, defaultEnabled: false, description: "Use FIPS Compliant Checksums - Ensure checksumming done by choco uses FIPS compliant algorithms. Not recommended unless required by FIPS Mode. Enabling on an existing installation could have unintended consequences related to upgrades/uninstalls. Available in 0.9.10+.");
config.Features.ShowNonElevatedWarnings = set_feature_flag(ApplicationParameters.Features.ShowNonElevatedWarnings, configFileSettings, defaultEnabled: true, description: "Show Non-Elevated Warnings - Display non-elevated warnings. Available in 0.10.4+.");
config.Features.ShowDownloadProgress = set_feature_flag(ApplicationParameters.Features.ShowDownloadProgress, configFileSettings, defaultEnabled: true, description: "Show Download Progress - Show download progress percentages in the CLI. Available in 0.10.4+.");
config.Features.StopOnFirstPackageFailure = set_feature_flag(ApplicationParameters.Features.StopOnFirstPackageFailure, configFileSettings, defaultEnabled: false, description: "Stop On First Package Failure - stop running install, upgrade or uninstall on first package failure instead of continuing with others. As this will affect upgrade all, it is normally recommended to leave this off. Available in 0.10.4+.");
config.Features.UseRememberedArgumentsForUpgrades = set_feature_flag(ApplicationParameters.Features.UseRememberedArgumentsForUpgrades, configFileSettings, defaultEnabled: false, description: "Use Remembered Arguments For Upgrades - when running upgrades, use arguments for upgrade that were used for installation ('remembered'). This is helpful when running upgrade for all packages. Available in 0.10.4+. This is considered in preview for 0.10.4 and will be flipped to on by default in a future release.");
config.Features.StopOnFirstPackageFailure = set_feature_flag(ApplicationParameters.Features.StopOnFirstPackageFailure, configFileSettings, defaultEnabled: false, description: "Stop On First Package Failure - Stop running install, upgrade or uninstall on first package failure instead of continuing with others. As this will affect upgrade all, it is normally recommended to leave this off. Available in 0.10.4+.");
config.Features.UseRememberedArgumentsForUpgrades = set_feature_flag(ApplicationParameters.Features.UseRememberedArgumentsForUpgrades, configFileSettings, defaultEnabled: false, description: "Use Remembered Arguments For Upgrades - When running upgrades, use arguments for upgrade that were used for installation ('remembered'). This is helpful when running upgrade for all packages. Available in 0.10.4+. This is considered in preview for 0.10.4 and will be flipped to on by default in a future release.");
config.Features.IgnoreUnfoundPackagesOnUpgradeOutdated = set_feature_flag(ApplicationParameters.Features.IgnoreUnfoundPackagesOnUpgradeOutdated, configFileSettings, defaultEnabled: false, description: "Ignore Unfound Packages On Upgrade Outdated - When checking outdated or upgrades, if a package is not found against sources specified, don't report the package at all. Available in 0.10.9+.");
config.Features.ScriptsCheckLastExitCode = set_feature_flag(ApplicationParameters.Features.ScriptsCheckLastExitCode, configFileSettings, defaultEnabled: false, description: "Scripts Check $LastExitCode (external commands) - Leave this off unless you absolutely need it while you fix your package scripts to use `throw 'error message'` or `Set-PowerShellExitCode #` instead of `exit #`. This behavior started in 0.9.10 and produced hard to find bugs. If the last external process exits successfully but with an exit code of not zero, this could cause hard to detect package failures. Available in 0.10.3+. Will be removed in 0.11.0.");
config.PromptForConfirmation = !set_feature_flag(ApplicationParameters.Features.AllowGlobalConfirmation, configFileSettings, defaultEnabled: false, description: "Prompt for confirmation in scripts or bypass.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon
"Ignore Pinned - Ignore pinned packages. Defaults to false. Available in 0.10.6+.",
option => configuration.OutdatedCommand.IgnorePinned = option != null)
.Add("ignore-unfound",
"Ignore Unfound Packages - Ignore packages that are not found on the sources used (or the defaults). Defaults to false. Available in 0.10.9+.",
option => configuration.OutdatedCommand.IgnoreUnfoundPackages = option != null)
"Ignore Unfound Packages - Ignore packages that are not found on the sources used (or the defaults). Overrides the default feature '{0}' set to '{1}'. Available in 0.10.9+.".format_with(ApplicationParameters.Features.IgnoreUnfoundPackagesOnUpgradeOutdated, configuration.Features.IgnoreUnfoundPackagesOnUpgradeOutdated.to_string()),
option => configuration.Features.IgnoreUnfoundPackagesOnUpgradeOutdated = option != null)
;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ public sealed class FeaturesConfiguration
public bool ShowDownloadProgress { get; set; }
public bool StopOnFirstPackageFailure { get; set; }
public bool UseRememberedArgumentsForUpgrades { get; set; }
public bool IgnoreUnfoundPackagesOnUpgradeOutdated { get; set; }

//todo remove in 0.11.0
public bool ScriptsCheckLastExitCode { get; set; }
Expand Down Expand Up @@ -500,7 +501,6 @@ public sealed class PinCommandConfiguration
public sealed class OutdatedCommandConfiguration
{
public bool IgnorePinned { get; set; }
public bool IgnoreUnfoundPackages { get; set; }
}

[Serializable]
Expand Down
2 changes: 1 addition & 1 deletion src/chocolatey/infrastructure.app/services/NugetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ public ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfigu

if (availablePackage == null)
{
if (config.OutdatedCommand.IgnoreUnfoundPackages) continue;
if (config.Features.IgnoreUnfoundPackagesOnUpgradeOutdated) continue;

string logMessage = "{0} was not found with the source(s) listed.{1} If you specified a particular version and are receiving this message, it is possible that the package name exists but the version does not.{1} Version: \"{2}\"; Source(s): \"{3}\"".format_with(packageName, Environment.NewLine, config.Version, config.Sources);
var unfoundResult = packageInstalls.GetOrAdd(packageName, new PackageResult(packageName, version.to_string(), null));
Expand Down

0 comments on commit 011ef6a

Please sign in to comment.