Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into 293-all-except
Browse files Browse the repository at this point in the history
Conflicts:
	src/chocolatey/infrastructure.app/services/NugetService.cs
  • Loading branch information
Christian Rondeau committed Jul 2, 2015
2 parents 96f641a + c30b3a1 commit 6a194ca
Show file tree
Hide file tree
Showing 20 changed files with 224 additions and 159 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,6 @@ public void should_leave_source_as_set()
because();
configuration.Sources.ShouldEqual(source);
}

[Fact]
public void should_set_source_to_local_location_when_localonly_is_true()
{
configuration.ListCommand.LocalOnly = true;
because();
configuration.Sources.ShouldEqual(ApplicationParameters.PackagesLocation);
}
}

public class when_noop_is_called : ChocolateyListCommandSpecsBase
Expand All @@ -233,7 +225,7 @@ public override void Because()
[Fact]
public void should_call_service_list_run()
{
packageService.Verify(c => c.list_run(configuration, true), Times.Once);
packageService.Verify(c => c.list_run(configuration), Times.Once);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,12 @@ public override void Context()
configuration.Sources = ApplicationParameters.PackagesLocation;
configuration.ListCommand.LocalOnly = true;
configuration.AllVersions = true;
var packageResults = new ConcurrentDictionary<string, PackageResult>();
packageResults.GetOrAdd("regular", new PackageResult(package.Object, null));
packageResults.GetOrAdd("pinned", new PackageResult(pinnedPackage.Object, null));
nugetService.Setup(n => n.list_run(It.IsAny<ChocolateyConfiguration>(), false)).Returns(packageResults);
var packageResults = new []
{
new PackageResult(package.Object, null),
new PackageResult(pinnedPackage.Object, null)
};
nugetService.Setup(n => n.list_run(It.IsAny<ChocolateyConfiguration>())).Returns(packageResults);
configuration.PinCommand.Command = PinCommandType.list;
}

Expand Down Expand Up @@ -412,7 +414,7 @@ public void should_call_nuget_service_list_run_when_command_is_list()
configuration.PinCommand.Command = PinCommandType.list;
command.run(configuration);

nugetService.Verify(n => n.list_run(It.IsAny<ChocolateyConfiguration>(), false), Times.Once);
nugetService.Verify(n => n.list_run(It.IsAny<ChocolateyConfiguration>()), Times.Once);
}

[Pending("NuGet is killing me with extension methods. Need to find proper item to mock out to return the package object.")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@
namespace chocolatey.infrastructure.app.commands
{
using System.Collections.Generic;
using System.Linq;
using attributes;
using commandline;
using configuration;
using domain;
using infrastructure.commands;
using logging;
using results;
using services;

[CommandFor(CommandNameType.list)]
[CommandFor(CommandNameType.search)]
public sealed class ChocolateyListCommand : ICommand
public sealed class ChocolateyListCommand : IListCommand<PackageResult>
{
private readonly IChocolateyPackageService _packageService;

Expand Down Expand Up @@ -66,12 +68,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 Expand Up @@ -115,7 +111,15 @@ public void noop(ChocolateyConfiguration configuration)
public void run(ChocolateyConfiguration configuration)
{
_packageService.ensure_source_app_installed(configuration);
_packageService.list_run(configuration, logResults: true);
// note: you must leave the .ToList() here or else the method won't be evaluated!
_packageService.list_run(configuration).ToList();
}

public IEnumerable<PackageResult> list(ChocolateyConfiguration configuration)
{
configuration.QuietOutput = true;
// here it's up to the caller to enumerate the results
return _packageService.list_run(configuration);
}

public bool may_require_admin_access()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,9 @@ public void run(ChocolateyConfiguration configuration)

public void list_pins(IPackageManager packageManager, ChocolateyConfiguration config)
{
var localPackages = _nugetService.list_run(config, logResults: false);
foreach (var pkg in localPackages.or_empty_list_if_null())
foreach (var pkg in _nugetService.list_run(config))
{
var pkgInfo = _packageInfoService.get_package_information(pkg.Value.Package);
var pkgInfo = _packageInfoService.get_package_information(pkg.Package);
if (pkgInfo != null && pkgInfo.IsPinned)
{
this.Log().Info(() => "{0}|{1}".format_with(pkgInfo.Package.Id, pkgInfo.Package.Version));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public override void run(ChocolateyConfiguration configuration)
{
if (configuration.ListCommand.LocalOnly)
{
_packageService.list_run(configuration,logResults:true);
_packageService.list_run(configuration);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,22 @@ private void append_output(StringBuilder propertyValues, string append)
public bool Force { get; set; }
public bool Noop { get; set; }
public bool HelpRequested { get; set; }

// TODO: Should look into using mutually exclusive output levels - Debug, Info (Regular), Error (Quiet)
// Verbose and Important are not part of the levels at all
/// <summary>
/// Gets or sets a value indicating whether output should be limited.
/// This supports the --limit-output parameter.
/// </summary>
/// <value><c>true</c> for regular output; <c>false</c> for limited output.</value>
public bool RegularOutput { get; set; }
/// <summary>
/// Gets or sets a value indicating whether console logging should be supressed.
/// This is for use by API calls which surface results in alternate forms.
/// </summary>
/// <value><c>true</c> for no output; <c>false</c> for regular or limited output.</value>
/// <remarks>This has only been implemented for NuGet List</remarks>
public bool QuietOutput { get; set; }
public bool PromptForConfirmation { get; set; }
public bool AcceptLicense { get; set; }
public bool AllowUnofficialBuild { get; set; }
Expand Down
1 change: 1 addition & 0 deletions src/chocolatey/infrastructure.app/domain/SourceType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public enum SourceType
webpi,
ruby,
python,
windowsfeature,
windowsfeatures,
cygwin,
}
Expand Down
12 changes: 6 additions & 6 deletions src/chocolatey/infrastructure.app/nuget/NugetList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace chocolatey.infrastructure.app.nuget

// ReSharper disable InconsistentNaming

public sealed class NugetList
public static class NugetList
{
public static IEnumerable<IPackage> GetPackages(ChocolateyConfiguration configuration, ILogger nugetLogger)
{
Expand All @@ -31,7 +31,7 @@ public static IEnumerable<IPackage> GetPackages(ChocolateyConfiguration configur

if (configuration.AllVersions)
{
return results.Where(PackageExtensions.IsListed).OrderBy(p => p.Id).ToList();
return results.Where(PackageExtensions.IsListed).OrderBy(p => p.Id);
}

if (configuration.Prerelease && packageRepository.SupportsPrereleasePackages)
Expand All @@ -44,10 +44,10 @@ public static IEnumerable<IPackage> GetPackages(ChocolateyConfiguration configur
}

return results.OrderBy(p => p.Id)
.AsEnumerable()
.Where(PackageExtensions.IsListed)
.Where(p => configuration.Prerelease || p.IsReleaseVersion())
.distinct_last(PackageEqualityComparer.Id, PackageComparer.Version).ToList();
.AsEnumerable()
.Where(PackageExtensions.IsListed)
.Where(p => configuration.Prerelease || p.IsReleaseVersion())
.distinct_last(PackageEqualityComparer.Id, PackageComparer.Version);
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/chocolatey/infrastructure.app/runners/GenericRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,13 @@ now be in a bad state. Only official builds are to be trusted.
return command;
}

private static void set_source_type(ChocolateyConfiguration config)
private void set_source_type(ChocolateyConfiguration config)
{
var sourceType = SourceType.normal;
Enum.TryParse(config.Sources, true, out sourceType);
config.SourceType = sourceType;

this.Log().Debug(()=> "The source '{0}' evaluated to a '{1}' source type".format_with(config.Sources,sourceType.to_string()));
}

public void run(ChocolateyConfiguration config, Container container, bool isConsole, Action<ICommand> parseArgs)
Expand Down
Loading

0 comments on commit 6a194ca

Please sign in to comment.