Skip to content

Commit

Permalink
(chocolateyGH-268) Add optional beforeUpgradeAction to upgrade_run me…
Browse files Browse the repository at this point in the history
…thod.

If not null, this action should be triggered in an update scenario but
in the forseeable future the action will only be used by the
NugetService (from where it will be used to trigger execution of the
chocolateyBeforeModify script described in chocolateyGH-268).
  • Loading branch information
Richard J Foster authored and Richard J Foster committed Mar 9, 2016
1 parent 4e2f9fc commit f708c92
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public ConcurrentDictionary<string, PackageResult> upgrade_noop(ChocolateyConfig
return new ConcurrentDictionary<string, PackageResult>(StringComparer.InvariantCultureIgnoreCase);
}

public ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfiguration config, Action<PackageResult> continueAction)
public ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfiguration config, Action<PackageResult> continueAction, Action<PackageResult> beforeUpgradeAction)
{
throw new NotImplementedException("{0} does not implement upgrade".format_with(APP_NAME));
}
Expand Down
5 changes: 3 additions & 2 deletions src/chocolatey/infrastructure.app/services/ISourceRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,15 @@ public interface ISourceRunner
/// <param name="config">The configuration.</param>
/// <param name="continueAction">The action to continue with for each noop test upgrade.</param>
ConcurrentDictionary<string, PackageResult> upgrade_noop(ChocolateyConfiguration config, Action<PackageResult> continueAction);

/// <summary>
/// Upgrades packages from NuGet related feeds
/// </summary>
/// <param name="config">The configuration.</param>
/// <param name="continueAction">The action to continue with when upgrade is successful.</param>
/// <param name="beforeUpgradeAction">The action (if any) to run on any currently installed package before triggering the upgrade.</param>
/// <returns>results of installs</returns>
ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfiguration config, Action<PackageResult> continueAction);
ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfiguration config, Action<PackageResult> continueAction, Action<PackageResult> beforeUpgradeAction = null);

/// <summary>
/// Run uninstall in noop mode
Expand Down
6 changes: 3 additions & 3 deletions src/chocolatey/infrastructure.app/services/NugetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -500,12 +500,12 @@ public ConcurrentDictionary<string, PackageResult> upgrade_noop(ChocolateyConfig
return upgrade_run(config, continueAction, performAction: false);
}

public ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfiguration config, Action<PackageResult> continueAction)
public ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfiguration config, Action<PackageResult> continueAction, Action<PackageResult> beforeUpgradeAction = null)
{
return upgrade_run(config, continueAction, performAction: true);
return upgrade_run(config, continueAction, performAction: true, beforeUpgradeAction: beforeUpgradeAction);
}

public ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfiguration config, Action<PackageResult> continueAction, bool performAction)
public ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfiguration config, Action<PackageResult> continueAction, bool performAction, Action<PackageResult> beforeUpgradeAction = null)
{
_fileSystem.create_directory_if_not_exists(ApplicationParameters.PackagesLocation);
var packageInstalls = new ConcurrentDictionary<string, PackageResult>(StringComparer.InvariantCultureIgnoreCase);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ public ConcurrentDictionary<string, PackageResult> upgrade_noop(ChocolateyConfig
return new ConcurrentDictionary<string, PackageResult>(StringComparer.InvariantCultureIgnoreCase);
}

public ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfiguration config, Action<PackageResult> continueAction)
public ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfiguration config, Action<PackageResult> continueAction, Action<PackageResult> beforeUpgradeAction)
{
set_executable_path_if_not_set();
var args = build_args(config, _upgradeArguments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public ConcurrentDictionary<string, PackageResult> upgrade_noop(ChocolateyConfig
return new ConcurrentDictionary<string, PackageResult>(StringComparer.InvariantCultureIgnoreCase);
}

public ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfiguration config, Action<PackageResult> continueAction)
public ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfiguration config, Action<PackageResult> continueAction, Action<PackageResult> beforeUpgradeAction)
{
throw new NotImplementedException("{0} does not implement upgrade".format_with(APP_NAME));
}
Expand Down
2 changes: 1 addition & 1 deletion src/chocolatey/infrastructure.app/services/WebPiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public ConcurrentDictionary<string, PackageResult> upgrade_noop(ChocolateyConfig
return new ConcurrentDictionary<string, PackageResult>(StringComparer.InvariantCultureIgnoreCase);
}

public ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfiguration config, Action<PackageResult> continueAction)
public ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfiguration config, Action<PackageResult> continueAction, Action<PackageResult> beforeUpgradeAction)
{
throw new NotImplementedException("{0} does not implement upgrade".format_with(APP_NAME));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public ConcurrentDictionary<string, PackageResult> upgrade_noop(ChocolateyConfig
return new ConcurrentDictionary<string, PackageResult>(StringComparer.InvariantCultureIgnoreCase);
}

public ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfiguration config, Action<PackageResult> continueAction)
public ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfiguration config, Action<PackageResult> continueAction, Action<PackageResult> beforeUpgradeAction)
{
set_executable_path_if_not_set();
throw new NotImplementedException("{0} does not implement upgrade".format_with(APP_NAME));
Expand Down

0 comments on commit f708c92

Please sign in to comment.