From e0e7ad344fcc19df2689b880e6fc4c041301b81d Mon Sep 17 00:00:00 2001 From: Matt Richardson Date: Wed, 19 Jun 2019 06:41:11 +1000 Subject: [PATCH] Allow opting out of delta push during package push (#3) * Allow opting out of delta push during package push Relates to https://github.com/OctopusDeploy/OctopusClients/pull/431 Fixes https://github.com/OctopusDeploy/Issues/issues/5585 --- source/Octo.Tests/Octo.Tests.csproj | 2 +- .../Commands/Package/PushCommand.cs | 20 ++++++++++++++----- source/Octopus.Cli/Octopus.Cli.csproj | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/source/Octo.Tests/Octo.Tests.csproj b/source/Octo.Tests/Octo.Tests.csproj index ddbca69dda..e3c91c1017 100644 --- a/source/Octo.Tests/Octo.Tests.csproj +++ b/source/Octo.Tests/Octo.Tests.csproj @@ -28,7 +28,7 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/source/Octopus.Cli/Commands/Package/PushCommand.cs b/source/Octopus.Cli/Commands/Package/PushCommand.cs index 1cc7e33fa5..0abbb370ce 100644 --- a/source/Octopus.Cli/Commands/Package/PushCommand.cs +++ b/source/Octopus.Cli/Commands/Package/PushCommand.cs @@ -22,16 +22,25 @@ public PushCommand(IOctopusAsyncRepositoryFactory repositoryFactory, IOctopusFil : base(clientFactory, repositoryFactory, fileSystem, commandOutputProvider) { var options = Options.For("Package pushing"); - options.Add("package=", "Package file to push. Specify multiple packages by specifying this argument multiple times: \n--package package1 --package package2", package => Packages.Add(EnsurePackageExists(fileSystem, package))); - options.Add("replace-existing", "If the package already exists in the repository, the default behavior is to reject the new package being pushed. You can pass this flag to overwrite the existing package.", replace => ReplaceExisting = true); - + options.Add("package=", "Package file to push. Specify multiple packages by specifying this argument multiple times: \n--package package1 --package package2", + package => Packages.Add(EnsurePackageExists(fileSystem, package))); + options.Add("replace-existing", "If the package already exists in the repository, the default behavior is to reject the new package being pushed. You can pass this flag to overwrite the existing package.", + replace => ReplaceExisting = true); + options.Add("use-delta-compression=", "Allows disabling of delta compression when uploading packages to the Octopus Server. Defaults to enabled.", + v => + { + if (!bool.TryParse(v, out var desiredValue)) + throw new CommandException($"The value '{v}' is not valid. Valid values are true or false."); + UseDeltaCompression = desiredValue; + }); pushedPackages = new List(); failedPackages = new List>(); } public HashSet Packages { get; } = new HashSet(StringComparer.OrdinalIgnoreCase); public bool ReplaceExisting { get; set; } - + public bool UseDeltaCompression { get; set; } = true; + public async Task Request() { if (Packages.Count == 0) throw new CommandException("Please specify a package to push"); @@ -45,7 +54,8 @@ public async Task Request() using (var fileStream = FileSystem.OpenFile(package, FileAccess.Read)) { await Repository.BuiltInPackageRepository - .PushPackage(Path.GetFileName(package), fileStream, ReplaceExisting).ConfigureAwait(false); + .PushPackage(Path.GetFileName(package), fileStream, ReplaceExisting, UseDeltaCompression) + .ConfigureAwait(false); } pushedPackages.Add(package); diff --git a/source/Octopus.Cli/Octopus.Cli.csproj b/source/Octopus.Cli/Octopus.Cli.csproj index 77aac1c5c2..55095467e3 100644 --- a/source/Octopus.Cli/Octopus.Cli.csproj +++ b/source/Octopus.Cli/Octopus.Cli.csproj @@ -27,7 +27,7 @@ - +