From df6434cd2d25b301b595e521d2e3b797e131e011 Mon Sep 17 00:00:00 2001 From: flightlevel <flightlevel@users.noreply.github.com> Date: Sun, 19 Nov 2017 18:37:47 +1100 Subject: [PATCH] Assist Release Note Creation Attempt 2 (#2165) Logic wasn't quite right for which commits to include --- appveyor.yml | 2 -- build.cake | 61 ++++++++++++++++++++++++++-------------------------- 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 122940e2..42764e4a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,4 @@ version: 0.8.{build} -pull_requests: - do_not_increment_build_number: true skip_tags: true image: Visual Studio 2017 configuration: Release diff --git a/build.cake b/build.cake index 73ece8c4..72860106 100644 --- a/build.cake +++ b/build.cake @@ -178,49 +178,48 @@ Task("Potential-Release-Notes") .IsDependentOn("Appveyor-Push-Artifacts") .Does(() => { - string tagHashLastGitHubTag = GitDescribe(".", false, GitDescribeStrategy.Tags, 100); - Information($"Tag and Hash of last release is: {tagHashLastGitHubTag}"); - - if (tagHashLastGitHubTag.Length > 40) - { - string lastReleaseHash = tagHashLastGitHubTag.Substring(tagHashLastGitHubTag.Length - 40); - Information($"Hash of first commit since last release is: {lastReleaseHash}" + Environment.NewLine); + string latestTag = GitDescribe(".", false, GitDescribeStrategy.Tags, 0); + Information($"Latest tag is: {latestTag}" + Environment.NewLine); + + List<GitCommit> relevantCommits = new List<GitCommit>(); - List<GitCommit> relevantCommits = new List<GitCommit>(); + var commitCollection = GitLog("./", 50); - var commitCollection = GitLog("./", 50); - bool foundHash = false; + foreach(GitCommit commit in commitCollection) + { + var commitTag = GitDescribe(".", commit.Sha, false, GitDescribeStrategy.Tags, 0); - foreach(GitCommit commit in commitCollection) + if (commitTag == latestTag) { relevantCommits.Add(commit); - - if (lastReleaseHash == commit.Sha) - { - foundHash = true; - break; - } } - - if (foundHash) + else { - List<string> notesList = new List<string>(); - - foreach(GitCommit commit in relevantCommits.AsEnumerable().Reverse().ToList()) - { - notesList.Add($"{commit.MessageShort} (Thank you @{commit.Author.Name})"); - } + break; + } + } - string buildNote = String.Join(Environment.NewLine, notesList); - Information(buildNote); + relevantCommits = relevantCommits.AsEnumerable().Reverse().Skip(1).ToList(); - FileAppendLines(workingDir + "\\BuildOutput\\ReleaseNotes.txt", notesList.ToArray()); - } - else + if (relevantCommits.Count() > 0) + { + List<string> notesList = new List<string>(); + + foreach(GitCommit commit in relevantCommits) { - Information($"Unable to create potential release notes as the hash ({lastReleaseHash}) of the first commit since the last release wasn't found in the last 50 commits"); + notesList.Add($"{commit.MessageShort} (Thank you @{commit.Author.Name})"); } + + string buildNote = String.Join(Environment.NewLine, notesList); + Information(buildNote); + + FileAppendLines(workingDir + "\\BuildOutput\\ReleaseNotes.txt", notesList.ToArray()); } + else + { + Information($"No commit messages found to create release notes"); + } + }); -- GitLab