Skip to content

Commit

Permalink
(chocolateyGH-293) Upgrade all except simple implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Rondeau committed Jun 27, 2015
1 parent b948920 commit 6df3297
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon
.Add("p=|password=",
"Password - the user's password to the source. Defaults to empty.",
option => configuration.SourceCommand.Password = option.remove_surrounding_quotes())
.Add("except=",
"Except - a comma-separated list of package names that should not be upgraded. Defaults to empty.",
option => configuration.UpgradeCommand.PackageNamesToSkip = option.remove_surrounding_quotes())
;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ public sealed class UpgradeCommandConfiguration
public bool FailOnUnfound { get; set; }
public bool FailOnNotInstalled { get; set; }
public bool NotifyOnlyAvailableUpgrades { get; set; }
public string PackageNamesToSkip { get; set; }
}

[Serializable]
Expand Down
14 changes: 13 additions & 1 deletion src/chocolatey/infrastructure.app/services/NugetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,12 +1045,24 @@ private void set_package_names_if_all_is_specified(ChocolateyConfiguration confi
config.Input = string.Empty;

var localPackages = list_run(config, logResults: false);
var packagesToUpdate = localPackages.Select((p) => p.Key);

if (!String.IsNullOrEmpty(config.UpgradeCommand.PackageNamesToSkip))
{
var packagesToSkip = config.UpgradeCommand.PackageNamesToSkip
.Split(',')
.Select(x => x.Trim())
.Where(x => !String.IsNullOrEmpty(x));

packagesToUpdate = packagesToUpdate.Where(x => !packagesToSkip.Contains(x, StringComparer.OrdinalIgnoreCase));
}

config.Input = input;
config.Noop = noop;
config.Prerelease = pre;
config.Sources = sources;
config.PackageNames = string.Join(ApplicationParameters.PackageNamesSeparator, localPackages.Select((p) => p.Key).or_empty_list_if_null());

config.PackageNames = string.Join(ApplicationParameters.PackageNamesSeparator, packagesToUpdate);

if (customAction != null) customAction.Invoke();
}
Expand Down

0 comments on commit 6df3297

Please sign in to comment.