From 31255f2a28c339c067ab44bc2b054b3469f96cf5 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Mon, 19 Apr 2021 21:32:29 +0100 Subject: [PATCH 1/4] (#112) Add new method for creating empty release This is similar to the overload for passing in an input file, the difference being that string.Empty is passed in, rather than reading the contents of the file, and then creating a release. --- .../Commands/CreateCommandTests.cs | 25 +++++++++++++++++++ .../Commands/CreateCommand.cs | 7 +++++- src/GitReleaseManager.Core/IVcsService.cs | 2 ++ .../Options/CreateSubOptions.cs | 3 +++ src/GitReleaseManager.Core/VcsService.cs | 6 +++++ src/GitReleaseManager.Tests/VcsServiceMock.cs | 5 ++++ 6 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/GitReleaseManager.Core.Tests/Commands/CreateCommandTests.cs b/src/GitReleaseManager.Core.Tests/Commands/CreateCommandTests.cs index de14eef5..24c49d95 100644 --- a/src/GitReleaseManager.Core.Tests/Commands/CreateCommandTests.cs +++ b/src/GitReleaseManager.Core.Tests/Commands/CreateCommandTests.cs @@ -27,6 +27,31 @@ public void Setup() _command = new CreateCommand(_vcsService, _logger); } + public async Task Should_Create_Empty_Release() + { + var options = new CreateSubOptions + { + RepositoryOwner = "owner", + RepositoryName = "repository", + TargetCommitish = "target commitish", + Prerelease = false, + AllowEmpty = true, + }; + + var releaseName = options.Name ?? options.Milestone; + + _vcsService.CreateEmptyReleaseAsync(options.RepositoryOwner, options.RepositoryName, options.Name, options.TargetCommitish, options.Prerelease) + .Returns(_release); + + var result = await _command.Execute(options).ConfigureAwait(false); + result.ShouldBe(0); + + await _vcsService.Received(1).CreateEmptyReleaseAsync(options.RepositoryOwner, options.RepositoryName, releaseName, options.TargetCommitish, options.Prerelease).ConfigureAwait(false); + _logger.Received(1).Information(Arg.Any()); + _logger.Received(1).Information(Arg.Any(), _release.HtmlUrl); + _logger.Received(1).Verbose(Arg.Any(), _release.Body); + } + [TestCase(null, 2)] [TestCase("release", 1)] public async Task Should_Create_Release_From_Milestone(string name, int logVerboseCount) diff --git a/src/GitReleaseManager.Core/Commands/CreateCommand.cs b/src/GitReleaseManager.Core/Commands/CreateCommand.cs index d4901a20..01acee3f 100644 --- a/src/GitReleaseManager.Core/Commands/CreateCommand.cs +++ b/src/GitReleaseManager.Core/Commands/CreateCommand.cs @@ -22,7 +22,12 @@ public async Task Execute(CreateSubOptions options) Release release; - if (!string.IsNullOrEmpty(options.Milestone)) + if (options.AllowEmpty) + { + _logger.Verbose("The AllowEmpty option has been passed, so an empty release will now be created"); + release = await _vcsService.CreateEmptyReleaseAsync(options.RepositoryOwner, options.RepositoryName, options.Name, options.TargetCommitish, options.Prerelease).ConfigureAwait(false); + } + else if (!string.IsNullOrEmpty(options.Milestone)) { _logger.Verbose("Milestone {Milestone} was specified", options.Milestone); var releaseName = options.Name; diff --git a/src/GitReleaseManager.Core/IVcsService.cs b/src/GitReleaseManager.Core/IVcsService.cs index bcf0f0b4..b07b98b7 100644 --- a/src/GitReleaseManager.Core/IVcsService.cs +++ b/src/GitReleaseManager.Core/IVcsService.cs @@ -6,6 +6,8 @@ namespace GitReleaseManager.Core { public interface IVcsService { + Task CreateEmptyReleaseAsync(string owner, string repository, string name, string targetCommitish, bool prerelease); + Task CreateReleaseFromMilestoneAsync(string owner, string repository, string milestone, string releaseName, string targetCommitish, IList assets, bool prerelease, string templateFilePath); Task CreateReleaseFromInputFileAsync(string owner, string repository, string name, string inputFilePath, string targetCommitish, IList assets, bool prerelease); diff --git a/src/GitReleaseManager.Core/Options/CreateSubOptions.cs b/src/GitReleaseManager.Core/Options/CreateSubOptions.cs index c3a66690..2f4a9004 100644 --- a/src/GitReleaseManager.Core/Options/CreateSubOptions.cs +++ b/src/GitReleaseManager.Core/Options/CreateSubOptions.cs @@ -26,5 +26,8 @@ public class CreateSubOptions : BaseVcsOptions [Option('e', "pre", Required = false, HelpText = "Creates the release as a pre-release.")] public bool Prerelease { get; set; } + + [Option("allowEmpty", Required = false, HelpText = "Allow the creation of an empty set of release notes. In this mode, milestone and input file path will be ignored.")] + public bool AllowEmpty { get; set; } } } \ No newline at end of file diff --git a/src/GitReleaseManager.Core/VcsService.cs b/src/GitReleaseManager.Core/VcsService.cs index 311b8130..ee6609c5 100644 --- a/src/GitReleaseManager.Core/VcsService.cs +++ b/src/GitReleaseManager.Core/VcsService.cs @@ -37,6 +37,12 @@ public VcsService(IVcsProvider vcsProvider, ILogger logger, IReleaseNotesBuilder _configuration = configuration; } + public async Task CreateEmptyReleaseAsync(string owner, string repository, string name, string targetCommitish, bool prerelease) + { + var release = await CreateReleaseAsync(owner, repository, name, name, string.Empty, prerelease, targetCommitish, null).ConfigureAwait(false); + return release; + } + public async Task CreateReleaseFromMilestoneAsync(string owner, string repository, string milestone, string releaseName, string targetCommitish, IList assets, bool prerelease, string templateFilePath) { var templatePath = ReleaseTemplates.DEFAULT_NAME; diff --git a/src/GitReleaseManager.Tests/VcsServiceMock.cs b/src/GitReleaseManager.Tests/VcsServiceMock.cs index 01b49624..2977d562 100644 --- a/src/GitReleaseManager.Tests/VcsServiceMock.cs +++ b/src/GitReleaseManager.Tests/VcsServiceMock.cs @@ -25,6 +25,11 @@ public VcsServiceMock() public int NumberOfCommits { get; set; } + public Task CreateEmptyReleaseAsync(string owner, string repository, string name, string targetCommitish, bool prerelease) + { + throw new System.NotImplementedException(); + } + public Task CreateReleaseFromMilestoneAsync(string owner, string repository, string milestone, string releaseName, string targetCommitish, IList assets, bool prerelease, string templateFilePath) { throw new System.NotImplementedException(); From a606dce57842681bfb564e5ec52fe087e9f25442 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Mon, 19 Apr 2021 21:41:18 +0100 Subject: [PATCH 2/4] (#112) Updated docs with new command option --- docs/input/docs/commands/create.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/input/docs/commands/create.md b/docs/input/docs/commands/create.md index a5024a65..cd38383a 100644 --- a/docs/input/docs/commands/create.md +++ b/docs/input/docs/commands/create.md @@ -6,10 +6,11 @@ Title: Create This is the main command of GitReleaseManager and it is used to create a draft set of release notes based on a milestone, which has been set up in GitHub. -There are two modes of operation when creating a Release. GitReleaseManager can +There are three modes of operation when creating a Release. GitReleaseManager can take as an input the name of the milestone to generate the release notes from. Or, it can take as an input the name of a file which contains the release notes to include in the Release. +Or, it can create a release that doesn't contain any release notes, i.e. it is empty. ## **Required Parameters** @@ -35,6 +36,8 @@ to include in the Release. logging to console. - `-t, --template`: The path to the file to be used as the template for the release notes. +- `--allowEmpty`: Allow the creation of an empty set of release notes. In this +mode, milestone and input file path will be ignored. ## **Template** @@ -61,3 +64,9 @@ gitreleasemanager.exe create -i c:\temp\releasenotes.md -n 0.1.0 --token fsdfsf6 gitreleasemanager.exe create --inputFilePath c:\temp\releasenotes.md --name 0.1.0 --token fsdfsf67657sdf5s7d5f --owner repoOwner --repository repo ``` + +Use GitReleaseManager to create an empty release: + +```bash +gitreleasemanager.exe create -n 0.1.0 --token fsdfsf67657sdf5s7d5f -o repoOwner -r repo --allowEmpty +``` From a2b63142d7c818b5b6b6e69bdfff2c7ddd580986 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Apr 2021 21:06:57 +0000 Subject: [PATCH 3/4] Bump YamlDotNet from 11.0.1 to 11.1.1 in /src Bumps [YamlDotNet](https://github.com/aaubry/YamlDotNet) from 11.0.1 to 11.1.1. - [Release notes](https://github.com/aaubry/YamlDotNet/releases) - [Commits](https://github.com/aaubry/YamlDotNet/compare/v11.0.1...v11.1.1) Signed-off-by: dependabot[bot] --- src/GitReleaseManager.Core/GitReleaseManager.Core.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GitReleaseManager.Core/GitReleaseManager.Core.csproj b/src/GitReleaseManager.Core/GitReleaseManager.Core.csproj index e1ff1404..064a075c 100644 --- a/src/GitReleaseManager.Core/GitReleaseManager.Core.csproj +++ b/src/GitReleaseManager.Core/GitReleaseManager.Core.csproj @@ -26,7 +26,7 @@ - + From 62f73cfd48e6080c5d9bf4eddd05fb74b0d29f63 Mon Sep 17 00:00:00 2001 From: AdmiringWorm Date: Mon, 19 Apr 2021 23:15:06 +0200 Subject: [PATCH 4/4] (build) Remove error action preference from build script --- build.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build.ps1 b/build.ps1 index ffa59b49..6f60ef35 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,6 +1,4 @@ -$ErrorActionPreference = 'Stop' - -$SCRIPT_NAME = "recipe.cake" +$SCRIPT_NAME = "recipe.cake" Write-Host "Restoring .NET Core tools" dotnet tool restore