Skip to content

Commit 0052b99

Browse files
committed
(chocolatey#2603) Export pin status
This adds the ability for the export command to include pins in the exported file. They will be exported if --include-arguments is specified, but can be excluded with --exclude-pins.
1 parent 675f4a9 commit 0052b99

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/chocolatey/infrastructure.app/commands/ChocolateyExportCommand.cs

+9
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ public void configure_argument_parser(OptionSet optionSet, ChocolateyConfigurati
5858
.Add("include-arguments|include-remembered-arguments",
5959
"Include Remembered Arguments - controls whether or not remembered arguments for each package appear in generated file. Defaults to false.",
6060
option => configuration.ExportCommand.IncludeRememberedPackageArguments = option != null)
61+
.Add("exclude-pins",
62+
"Exclude Pins - controls whether or not pins are included. Only applies if remembered arguments are exported. Defaults to false.",
63+
option => configuration.ExportCommand.ExcludePins = option != null)
6164
;
6265
}
6366

@@ -104,6 +107,7 @@ choco export [<options/switches>]
104107
choco export
105108
choco export --include-version-numbers
106109
choco export --include-version-numbers --include-remembered-arguments
110+
choco export --include-remembered-arguments --exclude-pins
107111
choco export ""'c:\temp\packages.config'""
108112
choco export ""'c:\temp\packages.config'"" --include-version-numbers
109113
choco export -o=""'c:\temp\packages.config'""
@@ -221,6 +225,11 @@ public void run(ChocolateyConfiguration configuration)
221225

222226
//Make sure to reset the configuration
223227
configuration = originalConfiguration.deep_copy();
228+
229+
if (!configuration.ExportCommand.ExcludePins && pkgInfo.IsPinned)
230+
{
231+
xw.WriteAttributeString("pinPackage", "true");
232+
}
224233
}
225234

226235
xw.WriteEndElement();

src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs

+1
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ public sealed class ExportCommandConfiguration
562562
{
563563
public bool IncludeVersionNumbers { get; set; }
564564
public bool IncludeRememberedPackageArguments { get; set; }
565+
public bool ExcludePins { get; set; }
565566

566567
public string OutputFilePath { get; set; }
567568
}

0 commit comments

Comments
 (0)