Skip to content

Commit

Permalink
(chocolatey#798) Add parameter to pin on install/upgrade
Browse files Browse the repository at this point in the history
This adds a parameter to pin packages after install or upgrade.
It re-uses the code in save_package_information to create the pin file.
  • Loading branch information
TheCakeIsNaOH committed Jan 17, 2022
1 parent 96aeca7 commit ffdb099
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon
configuration.Features.UsePackageRepositoryOptimizations = false;
}
})
.Add("pin|pinpackage|pin-package",
"Pin Package - Add a pin to the package after install. Available in 0.11.12+",
option => configuration.PinPackage = option != null
)
;

//todo: package name can be a url / installertype
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon
configuration.Features.UsePackageRepositoryOptimizations = false;
}
})
.Add("pin|pinpackage|pin-package",
"Pin Package - Add a pin to the package after upgrade. Available in 0.11.12+",
option => configuration.PinPackage = option != null
)
;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ private void append_output(StringBuilder propertyValues, string append)
public string DownloadChecksum64 { get; set; }
public string DownloadChecksumType { get; set; }
public string DownloadChecksumType64 { get; set; }
public bool PinPackage { get; set; }

/// <summary>
/// Configuration values provided by choco.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ public virtual void handle_package_result(PackageResult packageResult, Chocolate
handle_extension_packages(config, packageResult);
handle_template_packages(config, packageResult);
pkgInfo.Arguments = capture_arguments(config, packageResult);
pkgInfo.IsPinned = config.PinPackage;
}

var toolsLocation = Environment.GetEnvironmentVariable(ApplicationParameters.Environment.ChocolateyToolsLocation);
Expand Down

0 comments on commit ffdb099

Please sign in to comment.