Skip to content

Commit

Permalink
Allow opting out of delta push during package push (#3)
Browse files Browse the repository at this point in the history
* Allow opting out of delta push during package push

Relates to OctopusDeploy/OctopusClients#431
Fixes OctopusDeploy/Issues#5585
  • Loading branch information
matt-richardson authored Jun 18, 2019
1 parent 3cb3cd7 commit e0e7ad3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion source/Octo.Tests/Octo.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Nancy" Version="2.0.0-clinteastwood" />
<PackageReference Include="Octopus.Client" Version="6.7.1-split-octopusclient9" />
<PackageReference Include="Octopus.Client" Version="6.8.0" />
<PackageReference Include="Serilog.Sinks.TextWriter" Version="2.0.0" />
<PackageReference Include="NSubstitute" Version="2.0.3" />
<PackageReference Include="FluentAssertions" Version="4.19.4" />
Expand Down
20 changes: 15 additions & 5 deletions source/Octopus.Cli/Commands/Package/PushCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>();
failedPackages = new List<Tuple<string, Exception>>();
}

public HashSet<string> Packages { get; } = new HashSet<string>(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");
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion source/Octopus.Cli/Octopus.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<PackageReference Include="NuGet.Packaging.Core" Version="3.6.0-octopus-58692" />
<PackageReference Include="NuGet.Packaging.Core.Types" Version="3.6.0-octopus-58692" />
<PackageReference Include="NuGet.Versioning" Version="3.6.0-octopus-58692" />
<PackageReference Include="Octopus.Client" Version="6.7.1-split-octopusclient9" />
<PackageReference Include="Octopus.Client" Version="6.8.0" />
<PackageReference Include="Octostache" Version="2.3.0" />
<PackageReference Include="Serilog.Sinks.ColoredConsole" Version="2.0.0" />
<PackageReference Include="Serilog.Sinks.Trace" Version="2.0.0" />
Expand Down

0 comments on commit e0e7ad3

Please sign in to comment.