diff --git a/src/chocolatey.resources/helpers/ChocolateyTabExpansion.ps1 b/src/chocolatey.resources/helpers/ChocolateyTabExpansion.ps1 index 32c2df5201..4b3e22175b 100644 --- a/src/chocolatey.resources/helpers/ChocolateyTabExpansion.ps1 +++ b/src/chocolatey.resources/helpers/ChocolateyTabExpansion.ps1 @@ -66,7 +66,7 @@ $commandOptions = @{ download = "--internalize --internalize-all-urls --ignore-dependencies --installed-packages --ignore-unfound-packages --resources-location='' --download-location='' --outputdirectory='' --source='' --version='' --prerelease --user='' --password='' --cert='' --certpassword='' --append-use-original-location --recompile --disable-package-repository-optimizations -? --use-self-service" + $allcommands sync = "--output-directory='' --id='' --package-id='' -? --use-self-service" + $allcommands optimize = "--deflate-nupkg-only --id='' -? --use-self-service" + $allcommands - export = "--include-version-numbers --output-file-path='' --include-remembered-arguments -?" + $allcommands + export = "--include-version-numbers --output-file-path='' --include-remembered-arguments --exclude-pins -?" + $allcommands template = "--name=''" + $allcommands } diff --git a/src/chocolatey.tests/infrastructure.app/commands/ChocolateyExportCommandSpecs.cs b/src/chocolatey.tests/infrastructure.app/commands/ChocolateyExportCommandSpecs.cs index b989b9fcf5..2b62ea8864 100644 --- a/src/chocolatey.tests/infrastructure.app/commands/ChocolateyExportCommandSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/commands/ChocolateyExportCommandSpecs.cs @@ -120,6 +120,12 @@ public void should_add_include_remembered_arguments_to_the_option_set() { optionSet.Contains("include-remembered-arguments").ShouldBeTrue(); } + + [Fact] + public void should_add_exclude_pins_to_the_option_set() + { + optionSet.Contains("exclude-pins").ShouldBeTrue(); + } } public class when_handling_additional_argument_parsing : ChocolateyExportCommandSpecsBase diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyExportCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyExportCommand.cs index aa637d4bef..d0cf25cfe5 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyExportCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyExportCommand.cs @@ -64,6 +64,9 @@ public void configure_argument_parser(OptionSet optionSet, ChocolateyConfigurati .Add("include-arguments|include-remembered-arguments", "Include Remembered Arguments - controls whether or not remembered arguments for each package appear in generated file. Defaults to false. Available in 1.2.0+", option => configuration.ExportCommand.IncludeRememberedPackageArguments = option != null) + .Add("exclude-pins", + "Exclude Pins - controls whether or not pins are included. Only applies if remembered arguments are exported. Defaults to false.", + option => configuration.ExportCommand.ExcludePins = option != null) ; } @@ -110,6 +113,7 @@ choco export [] choco export choco export --include-version-numbers choco export --include-version-numbers --include-remembered-arguments + choco export --include-remembered-arguments --exclude-pins choco export ""'c:\temp\packages.config'"" choco export ""'c:\temp\packages.config'"" --include-version-numbers choco export -o=""'c:\temp\packages.config'"" @@ -147,7 +151,11 @@ public bool may_require_admin_access() public void noop(ChocolateyConfiguration configuration) { - this.Log().Info("Export would have been with options: {0} Output File Path={1}{0} Include Version Numbers:{2}{0} Include Remembered Arguments: {3}".format_with(Environment.NewLine, configuration.ExportCommand.OutputFilePath, configuration.ExportCommand.IncludeVersionNumbers, configuration.ExportCommand.IncludeRememberedPackageArguments)); + this.Log().Info("Export would have been with options: {0} Output File Path={1}{0} Include Version Numbers:{2}{0} Include Remembered Arguments: {3}{0} Exclude Pins: {4}".format_with( + Environment.NewLine, configuration.ExportCommand.OutputFilePath, + configuration.ExportCommand.IncludeVersionNumbers, + configuration.ExportCommand.IncludeRememberedPackageArguments, + configuration.ExportCommand.ExcludePins)); } public void run(ChocolateyConfiguration configuration) @@ -229,6 +237,11 @@ public void run(ChocolateyConfiguration configuration) // if (configuration.Features.FailOnStandardError) packageElement.FailOnStderr = true; // if (!configuration.Features.UsePowerShellHost) packageElement.UseSystemPowershell = true; + if (!configuration.ExportCommand.ExcludePins && pkgInfo.IsPinned) + { + xw.WriteAttributeString("pinPackage", "true"); + } + // Make sure to reset the configuration so as to be able to parse the next set of remembered arguments configuration.reset_config(); } diff --git a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs index 47e7eaaa5a..13e1848618 100644 --- a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs +++ b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs @@ -681,6 +681,7 @@ public sealed class ExportCommandConfiguration { public bool IncludeVersionNumbers { get; set; } public bool IncludeRememberedPackageArguments { get; set; } + public bool ExcludePins { get; set; } public string OutputFilePath { get; set; } }