Skip to content

Commit

Permalink
(chocolateyGH-223) Fix handling of LocalOnly for API
Browse files Browse the repository at this point in the history
Move test into the PackageService so it happens during execution regardless of how it's called.
Also did a minor refactor of line 431/436 to make the intent more readable.
  • Loading branch information
Jaykul committed Apr 5, 2015
1 parent 5742f16 commit 83ef921
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ public void configure_argument_parser(OptionSet optionSet, ChocolateyConfigurati
public void handle_additional_argument_parsing(IList<string> unparsedArguments, ChocolateyConfiguration configuration)
{
configuration.Input = string.Join(" ", unparsedArguments);

if (configuration.ListCommand.LocalOnly)
{
configuration.Sources = ApplicationParameters.PackagesLocation;
configuration.Prerelease = true;
}
}

public void handle_validation(ChocolateyConfiguration configuration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,14 @@ public IEnumerable<PackageResult> list_run(ChocolateyConfiguration config)
{
var packages = new List<IPackage>();

if (config.ListCommand.LocalOnly)
{
config.Sources = ApplicationParameters.PackagesLocation;
config.Prerelease = true;
}
foreach (var package in _nugetService.list_run(config))
{
if (!config.ListCommand.LocalOnly && !config.ListCommand.IncludeRegistryPrograms)
if (!config.ListCommand.LocalOnly || !config.ListCommand.IncludeRegistryPrograms)

This comment has been minimized.

Copy link
@ferventcoder

ferventcoder Apr 7, 2015

What does this change do?

This comment has been minimized.

Copy link
@Jaykul

Jaykul Apr 7, 2015

Author Owner

Unless we're going to call report_registry_programs then we must output here via yield return package

The test for calling report_registry_programs is on line 102, it is if(config.ListCommand.LocalOnly && config.ListCommand.IncludeRegistryPrograms) so obviously this code was wrong before and is correct now.

The previous incorrect code was mine -- and was a misinterpretation of the logic that was here before I changed this to stream output.

This comment has been minimized.

Copy link
@ferventcoder

ferventcoder Apr 7, 2015

Ah, guess i should evaluate this as part of the PR instead. :)

{
yield return package;
}
Expand Down Expand Up @@ -428,7 +433,7 @@ public ConcurrentDictionary<string, PackageResult> uninstall_run(ChocolateyConfi
this.Log().Info(@"Uninstalling the following packages:");
this.Log().Info(ChocolateyLoggers.Important, @"{0}".format_with(config.PackageNames));

foreach (var packageConfigFile in config.PackageNames.Split(new[] { ApplicationParameters.PackageNamesSeparator }, StringSplitOptions.RemoveEmptyEntries).or_empty_list_if_null().Where(p => p.EndsWith(".config")).ToList())
if (config.PackageNames.Split(new[] { ApplicationParameters.PackageNamesSeparator }, StringSplitOptions.RemoveEmptyEntries).or_empty_list_if_null().Any(p => p.EndsWith(".config")))

This comment has been minimized.

Copy link
@ferventcoder

ferventcoder Apr 7, 2015

Guess that works as well. :)

{
throw new ApplicationException("A packages.config file is only used with installs.");
}
Expand Down

0 comments on commit 83ef921

Please sign in to comment.