Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (GH-417) Choco config command
  (maint) Config output skip by contains password
  (GH-416) Features should contain description
  (GH-88) Modify existing source
  (GH-71) Sources can have explicit priority order
  (maint) resharper team settings
  (maint) Case insensitive String.contains
  (maint) formatting
  (GH-89) Note cpack has been deprecated
  (GH-33) Allow Shutting off checksumming

# Conflicts:
#	src/chocolatey/chocolatey.csproj
#	src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs
#
src/chocolatey/infrastructure.app/services/ChocolateyConfigSettingsService.cs
  • Loading branch information
ferventcoder committed Sep 21, 2015
2 parents 9952345 + 362507c commit 4e9451b
Show file tree
Hide file tree
Showing 26 changed files with 662 additions and 72 deletions.
1 change: 0 additions & 1 deletion src/chocolatey.console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ namespace chocolatey.console
using infrastructure.filesystem;
using infrastructure.licensing;
using infrastructure.logging;
using infrastructure.platforms;
using infrastructure.registration;
using infrastructure.services;
using resources;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ param(
[string] $checksumType = 'md5'
)
Write-Debug "Running 'Get-ChecksumValid' with file:`'$file`', checksum: `'$checksum`', checksumType: `'$checksumType`'";
if ($env:chocolateyIgnoreChecksums -eq 'true') {
Write-Warning "Ignoring checksums due to feature checksumFiles = false or config ignoreChecksums = true."
return
}
if ($checksum -eq '' -or $checksum -eq $null) { return }

if (!([System.IO.File]::Exists($file))) { throw "Unable to checksum a file that doesn't exist - Could not find file `'$file`'" }
Expand Down
1 change: 1 addition & 0 deletions src/chocolatey.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=sensible/@EntryIndexedValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;Profile name="sensible"&gt;&lt;CSArrangeThisQualifier&gt;True&lt;/CSArrangeThisQualifier&gt;&lt;CSMakeFieldReadonly&gt;True&lt;/CSMakeFieldReadonly&gt;&lt;CSOptimizeUsings&gt;&lt;OptimizeUsings&gt;True&lt;/OptimizeUsings&gt;&lt;EmbraceInRegion&gt;False&lt;/EmbraceInRegion&gt;&lt;RegionName&gt;&lt;/RegionName&gt;&lt;/CSOptimizeUsings&gt;&lt;CSShortenReferences&gt;True&lt;/CSShortenReferences&gt;&lt;CSReformatCode&gt;True&lt;/CSReformatCode&gt;&lt;CSRemoveCodeRedundancies&gt;True&lt;/CSRemoveCodeRedundancies&gt;&lt;CSUseAutoProperty&gt;True&lt;/CSUseAutoProperty&gt;&lt;CSUseVar&gt;&lt;BehavourStyle&gt;CAN_CHANGE_TO_IMPLICIT&lt;/BehavourStyle&gt;&lt;LocalVariableStyle&gt;IMPLICIT_WHEN_INITIALIZER_HAS_TYPE&lt;/LocalVariableStyle&gt;&lt;ForeachVariableStyle&gt;ALWAYS_EXPLICIT&lt;/ForeachVariableStyle&gt;&lt;/CSUseVar&gt;&lt;CSharpFormatDocComments&gt;True&lt;/CSharpFormatDocComments&gt;&lt;CSUpdateFileHeader&gt;True&lt;/CSUpdateFileHeader&gt;&lt;/Profile&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/SilentCleanupProfile/@EntryValue">sensible</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CommonFormatter/USE_INDENTS_FROM_MAIN_LANGUAGE_IN_FILE/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_IFELSE_BRACES_STYLE/@EntryValue">DO_NOT_CHANGE</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_CATCH_ON_NEW_LINE/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_ELSE_ON_NEW_LINE/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FINALLY_ON_NEW_LINE/@EntryValue">True</s:Boolean>
Expand Down
1 change: 1 addition & 0 deletions src/chocolatey.tests/chocolatey.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<Compile Include="GetChocolateySpecs.cs" />
<Compile Include="infrastructure.app\attributes\CommandForAttributeSpecs.cs" />
<Compile Include="infrastructure.app\commands\ChocolateyApiKeyCommandSpecs.cs" />
<Compile Include="infrastructure.app\commands\ChocolateyConfigCommandSpecs.cs" />
<Compile Include="infrastructure.app\commands\ChocolateyFeatureCommandSpecs.cs" />
<Compile Include="infrastructure.app\commands\ChocolateyInstallCommandSpecs.cs" />
<Compile Include="infrastructure.app\commands\ChocolateyListCommandSpecs.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
// Copyright © 2011 - Present RealDimensions Software, LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
//
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace chocolatey.tests.infrastructure.app.commands
{
using System;
using System.Collections.Generic;
using System.Linq;
using Moq;
using Should;
using chocolatey.infrastructure.app.attributes;
using chocolatey.infrastructure.app.commands;
using chocolatey.infrastructure.app.configuration;
using chocolatey.infrastructure.app.domain;
using chocolatey.infrastructure.app.services;
using chocolatey.infrastructure.commandline;

public class ChocolateyConfigCommandSpecs
{
public abstract class ChocolateyConfigCommandSpecsBase : TinySpec
{
protected ChocolateyConfigCommand command;
protected Mock<IChocolateyConfigSettingsService> configSettingsService = new Mock<IChocolateyConfigSettingsService>();
protected ChocolateyConfiguration configuration = new ChocolateyConfiguration();

public override void Context()
{
command = new ChocolateyConfigCommand(configSettingsService.Object);
}
}

public class when_implementing_command_for : ChocolateyConfigCommandSpecsBase
{
private List<string> results;

public override void Because()
{
results = command.GetType().GetCustomAttributes(typeof(CommandForAttribute), false).Cast<CommandForAttribute>().Select(a => a.CommandName).ToList();
}

[Fact]
public void should_implement_config()
{
results.ShouldContain(CommandNameType.config.to_string());
}
}

public class when_configurating_the_argument_parser : ChocolateyConfigCommandSpecsBase
{
private OptionSet optionSet;

public override void Context()
{
base.Context();
optionSet = new OptionSet();
}

public override void Because()
{
command.configure_argument_parser(optionSet, configuration);
}

[Fact]
public void should_add_name_to_the_option_set()
{
optionSet.Contains("name").ShouldBeTrue();
}

[Fact]
public void should_add_value_to_the_option_set()
{
optionSet.Contains("value").ShouldBeTrue();
}
}

public class when_noop_is_called : ChocolateyConfigCommandSpecsBase
{
public override void Because()
{
command.noop(configuration);
}

[Fact]
public void should_call_service_noop()
{
configSettingsService.Verify(c => c.noop(configuration), Times.Once);
}
}

public class when_run_is_called : ChocolateyConfigCommandSpecsBase
{
private Action because;

public override void Because()
{
because = () => command.run(configuration);
}

[Fact]
public void should_call_service_source_list_when_command_is_list()
{
configuration.ConfigCommand.Command = ConfigCommandType.list;
because();
configSettingsService.Verify(c => c.config_list(configuration), Times.Once);
}

[Fact]
public void should_call_service_source_disable_when_command_is_disable()
{
configuration.ConfigCommand.Command = ConfigCommandType.get;
because();
configSettingsService.Verify(c => c.config_get(configuration), Times.Once);
}

[Fact]
public void should_call_service_source_enable_when_command_is_enable()
{
configuration.ConfigCommand.Command = ConfigCommandType.set;
because();
configSettingsService.Verify(c => c.config_set(configuration), Times.Once);
}
}
}
}
12 changes: 12 additions & 0 deletions src/chocolatey/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ public static bool is_equal_to(this string input, string other)
return string.Compare(input, other, ignoreCase: true, culture: CultureInfo.InvariantCulture) == 0;
}

/// <summary>
/// Determines whether a string value contains a search value.
/// </summary>
/// <param name="input">The input.</param>
/// <param name="search">The value to search for.</param>
/// <param name="comparison">The comparison.</param>
/// <returns>True if the value to search for is in the input string</returns>
public static bool contains(this string input, string search, StringComparison comparison = StringComparison.OrdinalIgnoreCase)
{
return input.to_string().IndexOf(search, 0, comparison) >= 0;
}

/// <summary>
/// Removes quotes or apostrophes surrounding a string
/// </summary>
Expand Down
5 changes: 4 additions & 1 deletion src/chocolatey/chocolatey.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
</Compile>
<Compile Include="AssemblyExtensions.cs" />
<Compile Include="GetChocolatey.cs" />
<Compile Include="infrastructure.app\commands\ChocolateyConfigCommand.cs" />
<Compile Include="infrastructure.app\commands\ChocolateyFeatureCommand.cs" />
<Compile Include="infrastructure.app\commands\ChocolateyNewCommand.cs" />
<Compile Include="infrastructure.app\commands\ChocolateyOutdatedCommand.cs" />
Expand All @@ -92,9 +93,11 @@
<Compile Include="infrastructure.app\commands\ChocolateyUpgradeCommand.cs" />
<Compile Include="infrastructure.app\commands\ChocolateyVersionCommand.cs" />
<Compile Include="infrastructure.app\configuration\ChocolateySource.cs" />
<Compile Include="infrastructure.app\configuration\ConfigFileConfigSetting.cs" />
<Compile Include="infrastructure.app\configuration\ConfigFileFeatureSetting.cs" />
<Compile Include="infrastructure.app\configuration\PackagesConfigFilePackageSetting.cs" />
<Compile Include="infrastructure.app\configuration\PackagesConfigFileSettings.cs" />
<Compile Include="infrastructure.app\domain\ConfigCommandType.cs" />
<Compile Include="infrastructure.app\domain\FeatureCommandType.cs" />
<Compile Include="infrastructure.app\domain\InstallerBase.cs" />
<Compile Include="infrastructure.app\domain\PackageFile.cs" />
Expand Down Expand Up @@ -285,4 +288,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
7 changes: 7 additions & 0 deletions src/chocolatey/infrastructure.app/ApplicationParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ public static class Tools
public static readonly string ShimGenExe = _fileSystem.combine_paths(InstallLocation, "tools", "shimgen.exe");
}

public static class ConfigSettings
{
public static readonly string CacheLocation = "cacheLocation";
public static readonly string ContainsLegacyPackageInstalls = "containsLegacyPackageInstalls";
public static readonly string CommandExecutionTimeoutSeconds = "commandExecutionTimeoutSeconds";
}

public static class Features
{
public static readonly string CheckSumFiles = "checksumFiles";
Expand Down
Loading

0 comments on commit 4e9451b

Please sign in to comment.