diff --git a/build/_build.csproj.DotSettings b/build/_build.csproj.DotSettings index 7bc28484c4..337271da98 100644 --- a/build/_build.csproj.DotSettings +++ b/build/_build.csproj.DotSettings @@ -16,6 +16,8 @@ False <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy><Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy> True True True @@ -24,4 +26,5 @@ True True True - True + True + True diff --git a/source/Octo.Tests/Commands/ListReleasesCommandFixture.cs b/source/Octo.Tests/Commands/ListReleasesCommandFixture.cs index 296595a80f..08dcc94493 100644 --- a/source/Octo.Tests/Commands/ListReleasesCommandFixture.cs +++ b/source/Octo.Tests/Commands/ListReleasesCommandFixture.cs @@ -68,7 +68,7 @@ public async Task ShouldGetListOfReleases() Version = "1.2.3", Assembled = DateTimeOffset.MaxValue, ReleaseNotes = "Version controlled release notes", - VersionControlReference = new GitReferenceResource + GitReference = new SnapshotGitReferenceResource { GitCommit = "87a072ad2b4a2e9bf2d7ff84d8636a032786394d", GitRef = "main" @@ -124,7 +124,7 @@ public async Task JsonFormat_ShouldBeWellFormed() Version = "1.2.3", Assembled = DateTimeOffset.MaxValue, ReleaseNotes = "Version controlled release notes", - VersionControlReference = new GitReferenceResource + GitReference = new SnapshotGitReferenceResource { GitCommit = "87a072ad2b4a2e9bf2d7ff84d8636a032786394d", GitRef = "main" diff --git a/source/Octo.Tests/Octo.Tests.csproj b/source/Octo.Tests/Octo.Tests.csproj index d59ca56c1b..0779590d97 100644 --- a/source/Octo.Tests/Octo.Tests.csproj +++ b/source/Octo.Tests/Octo.Tests.csproj @@ -12,14 +12,21 @@ + + CS0618 + + + + CS0618 + + all runtime; build; native; contentfiles; analyzers - - + diff --git a/source/Octopus.Cli/Commands/ApiCommand.cs b/source/Octopus.Cli/Commands/ApiCommand.cs index a2779e9ea9..8c961e093a 100644 --- a/source/Octopus.Cli/Commands/ApiCommand.cs +++ b/source/Octopus.Cli/Commands/ApiCommand.cs @@ -270,10 +270,10 @@ protected static IEnumerable FormatReleasePropertiesAsStrings(ReleaseRes "Package Versions: " + GetPackageVersionsAsString(release.SelectedPackages), "Release Notes: " + GetReleaseNotes(release) }; - if (!string.IsNullOrEmpty(release.VersionControlReference?.GitRef)) - releaseProperties.Add("Git Reference: " + release.VersionControlReference.GitRef); - if (!string.IsNullOrEmpty(release.VersionControlReference?.GitCommit)) - releaseProperties.Add("Git Commit: " + release.VersionControlReference.GitCommit); + if (!string.IsNullOrEmpty(release.GitReference?.GitRef)) + releaseProperties.Add("Git Reference: " + release.GitReference.GitRef); + if (!string.IsNullOrEmpty(release.GitReference?.GitCommit)) + releaseProperties.Add("Git Commit: " + release.GitReference.GitCommit); return releaseProperties; } diff --git a/source/Octopus.Cli/Commands/Package/PushMetadataCommand.cs b/source/Octopus.Cli/Commands/Package/PushMetadataCommand.cs deleted file mode 100644 index 468a7845aa..0000000000 --- a/source/Octopus.Cli/Commands/Package/PushMetadataCommand.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using System.Threading.Tasks; -using Newtonsoft.Json; -using Octopus.Cli.Repositories; -using Octopus.Cli.Util; -using Octopus.Client; -using Octopus.Client.Model; -using Octopus.Client.Model.PackageMetadata; -using Octopus.CommandLine; -using Octopus.CommandLine.Commands; - -namespace Octopus.Cli.Commands.Package -{ - [Command("push-metadata", Description = "Pushes package metadata to Octopus Server. Deprecated. Please use the build-information command for Octopus Server 2019.10.0 and above.")] - public class PushMetadataCommand : ApiCommand, ISupportFormattedOutput - { - static readonly OverwriteMode DefaultOverwriteMode = OverwriteMode.FailIfExists; - - OctopusPackageMetadataMappedResource resultResource; - - public PushMetadataCommand(IOctopusAsyncRepositoryFactory repositoryFactory, IOctopusFileSystem fileSystem, IOctopusClientFactory clientFactory, ICommandOutputProvider commandOutputProvider) - : base(clientFactory, repositoryFactory, fileSystem, commandOutputProvider) - { - var options = Options.For("Package metadata pushing"); - options.Add("package-id=", "The ID of the package, e.g., 'MyCompany.MyApp'.", v => PackageId = v); - options.Add("version=", "The version of the package; defaults to a timestamp-based version.", v => Version = v); - options.Add("metadata-file=", "Octopus Package metadata Json file.", file => MetadataFile = file); - options.Add("overwrite-mode=", $"Determines behavior if the package already exists in the repository. Valid values are {Enum.GetNames(typeof(OverwriteMode)).ReadableJoin()}. Default is {DefaultOverwriteMode}.", mode => OverwriteMode = mode); - options.Add("replace-existing", "If the package metadata already exists in the repository, the default behavior is to reject the new package metadata being pushed. You can pass this flag to overwrite the existing package metadata. This flag may be deprecated in a future version; passing it is the same as using the OverwriteExisting overwrite-mode.", replace => OverwriteMode = OverwriteMode.OverwriteExisting); - } - - public string PackageId { get; set; } - public string Version { get; set; } - public string MetadataFile { get; set; } - public OverwriteMode OverwriteMode { get; set; } = DefaultOverwriteMode; - - public async Task Request() - { - if (string.IsNullOrEmpty(MetadataFile)) - throw new CommandException("Please specify the metadata file."); - if (string.IsNullOrEmpty(PackageId)) - throw new CommandException("Please specify the package id."); - if (string.IsNullOrEmpty(Version)) - throw new CommandException("Please specify the package version."); - - if (!FileSystem.FileExists(MetadataFile)) - throw new CommandException($"Metadata file '{MetadataFile}' does not exist"); - - var rootDocument = await Repository.LoadRootDocument(); - if (rootDocument.HasLink("BuildInformation")) - commandOutputProvider.Warning("This Octopus server supports the BuildInformation API, we recommend using the `build-information` command as `package-metadata` has been deprecated."); - - commandOutputProvider.Debug("Pushing package metadata: {PackageId}...", PackageId); - - var fileContent = FileSystem.ReadAllText(MetadataFile); - var octopusPackageMetadata = JsonConvert.DeserializeObject(fileContent); - - resultResource = await Repository.PackageMetadataRepository.Push(PackageId, Version, octopusPackageMetadata, OverwriteMode); - } - - public void PrintDefaultOutput() - { - commandOutputProvider.Debug("Push successful"); - } - - public void PrintJsonOutput() - { - commandOutputProvider.Json(resultResource); - } - } -} diff --git a/source/Octopus.Cli/Commands/Releases/CreateReleaseCommand.cs b/source/Octopus.Cli/Commands/Releases/CreateReleaseCommand.cs index a57caa65b8..4aca6df8b6 100644 --- a/source/Octopus.Cli/Commands/Releases/CreateReleaseCommand.cs +++ b/source/Octopus.Cli/Commands/Releases/CreateReleaseCommand.cs @@ -185,7 +185,7 @@ public async Task Request() { ReleaseNotes = ReleaseNotes, SelectedPackages = plan.GetSelections(), - VersionControlReference = new GitReferenceResource + GitReference = new SnapshotGitReferenceResource { GitRef = GitReference, GitCommit = GitCommit @@ -195,8 +195,8 @@ public async Task Request() .ConfigureAwait(false); commandOutputProvider.Information("Release {Version:l} created successfully!", release.Version); - if (!string.IsNullOrEmpty(release.VersionControlReference?.GitCommit)) - commandOutputProvider.Information("Release created from commit {Commit:l} of git reference {GitRef:l}.", release.VersionControlReference.GitCommit, release.VersionControlReference.GitRef); + if (!string.IsNullOrEmpty(release.GitReference?.GitCommit)) + commandOutputProvider.Information("Release created from commit {Commit:l} of git reference {GitRef:l}.", release.GitReference.GitCommit, release.GitReference.GitRef); commandOutputProvider.ServiceMessage("setParameter", new { name = "octo.releaseNumber", value = release.Version }); commandOutputProvider.TfsServiceMessage(ServerBaseUrl, project, release); diff --git a/source/Octopus.Cli/Commands/Releases/ListReleasesCommand.cs b/source/Octopus.Cli/Commands/Releases/ListReleasesCommand.cs index a193277e2c..1d20a8f194 100644 --- a/source/Octopus.Cli/Commands/Releases/ListReleasesCommand.cs +++ b/source/Octopus.Cli/Commands/Releases/ListReleasesCommand.cs @@ -76,8 +76,8 @@ public void PrintJsonOutput() r.Assembled, PackageVersions = GetPackageVersionsAsString(r.SelectedPackages), ReleaseNotes = GetReleaseNotes(r), - GitReference = r.VersionControlReference?.GitRef, - r.VersionControlReference?.GitCommit + GitReference = r.GitReference?.GitRef, + r.GitReference?.GitCommit }) })); } diff --git a/source/Octopus.Cli/Octopus.Cli.csproj b/source/Octopus.Cli/Octopus.Cli.csproj index 84ff594397..371fc1df5a 100644 --- a/source/Octopus.Cli/Octopus.Cli.csproj +++ b/source/Octopus.Cli/Octopus.Cli.csproj @@ -18,6 +18,14 @@ NU5104 + + NU5104;CS0618 + + + + NU5104;CS0618 + + all @@ -31,7 +39,7 @@ - + diff --git a/source/OctopusCli.sln.DotSettings b/source/OctopusCli.sln.DotSettings index f05dab78fe..d6b98e5605 100644 --- a/source/OctopusCli.sln.DotSettings +++ b/source/OctopusCli.sln.DotSettings @@ -199,6 +199,8 @@ <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"><ExtraRule Prefix="" Suffix="" Style="AaBb_AaBb" /></Policy> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy><Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb"><ExtraRule Prefix="" Suffix="" Style="AaBb" /></Policy> True F:\OctopusGit\OctopusDeploy\source\Octopus.sln.DotSettings @@ -211,11 +213,13 @@ True True True + True True True True True True + True True False False