Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (GH-994) Outdated - Add ignore-pinned switch
  • Loading branch information
ferventcoder committed May 19, 2017
2 parents 0822cbe + 5e4d9a6 commit 237de6a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ $commandOptions = @{
info = "--pre --lo --source='' --user= --password= --local-only --prerelease" + $allcommands
install = "-y -whatif -? --pre --version= --params='' --install-arguments='' --override-arguments --ignore-dependencies --source='' --source='windowsfeatures' --source='webpi' --user= --password= --prerelease --forcex86 --not-silent --package-parameters='' --allow-downgrade --force-dependencies --require-checksums --use-package-exit-codes --ignore-package-exit-codes --skip-automation-scripts --allow-multiple-versions --ignore-checksums --allow-empty-checksums --allow-empty-checksums-secure --download-checksum='' --download-checksum-type='' --download-checksum-x64='' --download-checksum-type-x64='' --stop-on-first-package-failure" + $proInstallUpgradeOptions + $allcommands
pin = "--name= --version= -?" + $allcommands
outdated = "-? --source='' --user= --password=" + $allcommands
outdated = "-? --source='' --user= --password= --ignore-pinned" + $allcommands
upgrade = "-y -whatif -? --pre --version= --except='' --params='' --install-arguments='' --override-arguments --ignore-dependencies --source='' --source='windowsfeatures' --source='webpi' --user= --password= --prerelease --forcex86 --not-silent --package-parameters='' --allow-downgrade --allow-multiple-versions --require-checksums --use-package-exit-codes --ignore-package-exit-codes --skip-automation-scripts --fail-on-unfound --fail-on-not-installed --ignore-checksums --allow-empty-checksums --allow-empty-checksums-secure --download-checksum='' --download-checksum-type='' --download-checksum-x64='' --download-checksum-type-x64='' --exclude-prerelease --stop-on-first-package-failure --use-remembered-options --ignore-remembered-options" + $proInstallUpgradeOptions + $allcommands
uninstall = "-y -whatif -? --force-dependencies --remove-dependencies --all-versions --source='windowsfeatures' --source='webpi' --version= --uninstall-arguments='' --override-arguments --not-silent --params='' --package-parameters='' --use-package-exit-codes --ignore-package-exit-codes --skip-automation-scripts --use-autouninstaller --skip-autouninstaller --fail-on-autouninstaller --ignore-autouninstaller-failure --stop-on-first-package-failure" + $proUninstallOptions + $allcommands
new = "--template-name= --output-directory='' --automaticpackage --version= --maintainer='' packageversion= maintainername='' maintainerrepo='' installertype= url='' url64='' silentargs='' --use-built-in-template -?" + $proNewOptions + $allcommands
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ public void should_add_short_version_of_password_to_the_option_set()
{
optionSet.Contains("p").ShouldBeTrue();
}

[Fact]
public void should_add_ignore_pinned_to_the_option_set()
{
optionSet.Contains("ignore-pinned").ShouldBeTrue();
}
}

public class when_noop_is_called : ChocolateyOutdatedCommandSpecsBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon
.Add("cp=|certpassword=",
"Certificate Password - the client certificate's password to the source. Defaults to empty. Available in 0.9.10+.",
option => configuration.SourceCommand.CertificatePassword = option.remove_surrounding_quotes())
.Add("ignore-pinned",
"Ignore Pinned - Ignore pinned packages. Defaults to false.",
option => configuration.OutdatedCommand.IgnorePinned = option != null)
;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public ChocolateyConfiguration()
ApiKeyCommand = new ApiKeyCommandConfiguration();
PushCommand = new PushCommandConfiguration();
PinCommand = new PinCommandConfiguration();
OutdatedCommand = new OutdatedCommandConfiguration();
Proxy = new ProxyConfiguration();
#if DEBUG
AllowUnofficialBuild = true;
Expand Down Expand Up @@ -313,8 +314,16 @@ private void append_output(StringBuilder propertyValues, string append)
/// <remarks>
/// On .NET 4.0, get error CS0200 when private set - see http://stackoverflow.com/a/23809226/18475
/// </remarks>
public PinCommandConfiguration PinCommand { get; set; }

public PinCommandConfiguration PinCommand { get; set; }

/// <summary>
/// Configuration related specifically to Outdated command
/// </summary>
/// <remarks>
/// On .NET 4.0, get error CS0200 when private set - see http://stackoverflow.com/a/23809226/18475
/// </remarks>
public OutdatedCommandConfiguration OutdatedCommand { get; set; }

/// <summary>
/// Configuration related specifically to proxies.
/// </summary>
Expand Down Expand Up @@ -475,6 +484,12 @@ public sealed class PinCommandConfiguration
public PinCommandType Command { get; set; }
}

[Serializable]
public sealed class OutdatedCommandConfiguration
{
public bool IgnorePinned { get; set; }
}

[Serializable]
public sealed class ApiKeyCommandConfiguration
{
Expand Down
11 changes: 8 additions & 3 deletions src/chocolatey/infrastructure.app/services/NugetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,14 @@ public ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfigu
continue;
}

var pkgInfo = _packageInfoService.get_package_information(installedPackage);
bool isPinned = pkgInfo != null && pkgInfo.IsPinned;

if (isPinned && config.OutdatedCommand.IgnorePinned)
{
continue;
}

if (version != null && version < installedPackage.Version && !config.AllowMultipleVersions && !config.AllowDowngrade)
{
string logMessage = "A newer version of {0} (v{1}) is already installed.{2} Use --allow-downgrade or --force to attempt to upgrade to older versions, or use side by side to allow multiple versions.".format_with(installedPackage.Id, installedPackage.Version, Environment.NewLine);
Expand All @@ -631,9 +639,6 @@ public ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfigu
continue;
}

var pkgInfo = _packageInfoService.get_package_information(installedPackage);
bool isPinned = pkgInfo != null && pkgInfo.IsPinned;

// if we have a prerelease installed, we want to have it upgrade based on newer prereleases
var originalPrerelease = config.Prerelease;
if (!string.IsNullOrWhiteSpace(installedPackage.Version.SpecialVersion) && !config.UpgradeCommand.ExcludePrerelease)
Expand Down

0 comments on commit 237de6a

Please sign in to comment.