From 55d8356c8a79278d94277ee41a0ae810355c87d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Gr=C3=B6nlund?= Date: Sat, 9 Oct 2021 16:33:53 +0200 Subject: [PATCH] (GH-1669) Add SemVer support to ReleaseNotesParser * fixes #1669 --- .../Unit/ReleaseNotesAliasesTests.cs | 2 + .../Unit/ReleaseNotesParserTests.cs | 42 ++- .../Unit/ReleaseNotesTests.cs | 16 +- src/Cake.Common/ReleaseNotes.cs | 37 +- src/Cake.Common/ReleaseNotesAliases.cs | 1 + src/Cake.Common/ReleaseNotesParser.cs | 30 +- src/Cake.Common/SemanticVersion.cs | 339 ++++++++++++++++++ .../Cake.Common/ReleaseNotesAliases.cake | 81 ++++- .../Cake.Common/ReleaseNotesSemVer.md | 8 + 9 files changed, 525 insertions(+), 31 deletions(-) create mode 100644 src/Cake.Common/SemanticVersion.cs create mode 100644 tests/integration/resources/Cake.Common/ReleaseNotesSemVer.md diff --git a/src/Cake.Common.Tests/Unit/ReleaseNotesAliasesTests.cs b/src/Cake.Common.Tests/Unit/ReleaseNotesAliasesTests.cs index b24f3994b7..fca05ac075 100644 --- a/src/Cake.Common.Tests/Unit/ReleaseNotesAliasesTests.cs +++ b/src/Cake.Common.Tests/Unit/ReleaseNotesAliasesTests.cs @@ -61,6 +61,7 @@ public void Should_Read_Content_Of_File_And_Parse_It() // Then Assert.Equal("1.2.3", result[0].Version.ToString()); + Assert.Equal("1.2.3", result[0].SemVersion.ToString()); } } @@ -82,6 +83,7 @@ public void Should_Return_The_Latest_Release_Notes() // Then Assert.Equal("1.2.5", result.Version.ToString()); + Assert.Equal("1.2.5", result.SemVersion.ToString()); } } } diff --git a/src/Cake.Common.Tests/Unit/ReleaseNotesParserTests.cs b/src/Cake.Common.Tests/Unit/ReleaseNotesParserTests.cs index 0d6d0c29ff..364f12adf5 100644 --- a/src/Cake.Common.Tests/Unit/ReleaseNotesParserTests.cs +++ b/src/Cake.Common.Tests/Unit/ReleaseNotesParserTests.cs @@ -1,10 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. - using Cake.Core; using Xunit; - namespace Cake.Common.Tests.Unit { public sealed class ReleaseNotesParserTests @@ -67,6 +65,7 @@ public void Should_Parse_Release_Note_Version() // Then Assert.Equal("0.1.9", result[0].Version.ToString()); + Assert.Equal("0.1.9", result[0].SemVersion.ToString()); } [Fact] @@ -129,6 +128,8 @@ public void Should_Return_Release_Notes_In_Descending_Order() Assert.Equal(2, result.Count); Assert.Equal("0.1.10", result[0].Version.ToString()); Assert.Equal("0.1.9", result[1].Version.ToString()); + Assert.Equal("0.1.10", result[0].SemVersion.ToString()); + Assert.Equal("0.1.9", result[1].SemVersion.ToString()); } [Fact] @@ -159,6 +160,40 @@ public void Should_Set_RawVersionLine_Property_To_Line_Containing_Version_Number // Then Assert.Equal("### New in 0.1.9-beta1 (Releases 2014/06/28)", result[0].RawVersionLine); } + + [Fact] + public void Should_Parse_Release_Note_Version_With_Prerelease() + { + // Given + var parser = new ReleaseNotesParser(); + const string content = "### New in 0.1.9-beta1 (Releases 2014/06/28)\nLine 1\n \n\t\n"; + + // When + var result = parser.Parse(content); + + // Then + Assert.Equal("0.1.9", result[0].Version.ToString()); + Assert.Equal("0.1.9-beta1", result[0].SemVersion.ToString()); + } + + [Fact] + public void Should_Return_Multiple_Release_Notes_With_Prerelease() + { + // Given + var parser = new ReleaseNotesParser(); + const string content = "### New in 0.1.9-alpha1 (Releases 2014/06/28)\n* Line 1\n" + + "###New in 0.1.10-gamma3\n* Line 2\n Line 3"; + + // When + var result = parser.Parse(content); + + // Then + Assert.Equal(2, result.Count); + Assert.Equal("0.1.10", result[0].Version.ToString()); + Assert.Equal("0.1.9", result[1].Version.ToString()); + Assert.Equal("0.1.10-gamma3", result[0].SemVersion.ToString()); + Assert.Equal("0.1.9-alpha1", result[1].SemVersion.ToString()); + } } public sealed class SimpleFormat @@ -190,6 +225,7 @@ public void Should_Parse_Release_Note_Version() // Then Assert.Equal("0.1.9", result[0].Version.ToString()); + Assert.Equal("0.1.9", result[0].SemVersion.ToString()); } [Fact] @@ -249,6 +285,8 @@ public void Should_Return_Release_Notes_In_Descending_Order() Assert.Equal(2, result.Count); Assert.Equal("0.1.10", result[0].Version.ToString()); Assert.Equal("0.1.9", result[1].Version.ToString()); + Assert.Equal("0.1.10", result[0].SemVersion.ToString()); + Assert.Equal("0.1.9", result[1].SemVersion.ToString()); } } } diff --git a/src/Cake.Common.Tests/Unit/ReleaseNotesTests.cs b/src/Cake.Common.Tests/Unit/ReleaseNotesTests.cs index 47946bc890..013870fe41 100644 --- a/src/Cake.Common.Tests/Unit/ReleaseNotesTests.cs +++ b/src/Cake.Common.Tests/Unit/ReleaseNotesTests.cs @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. - +using System; using System.Linq; using Xunit; @@ -15,11 +15,23 @@ public sealed class TheConstructor public void Should_Throw_If_Version_Is_Null() { // Given, When - var result = Record.Exception(() => new ReleaseNotes(null, Enumerable.Empty(), null)); + Version version = null; + var result = Record.Exception(() => new ReleaseNotes(version, Enumerable.Empty(), null)); // Then AssertEx.IsArgumentNullException(result, "version"); } + + [Fact] + public void Should_Throw_If_SemVersion_Is_Null() + { + // Given, When + SemVersion semVersion = null; + var result = Record.Exception(() => new ReleaseNotes(semVersion, Enumerable.Empty(), null)); + + // Then + AssertEx.IsArgumentNullException(result, "semVersion"); + } } } } \ No newline at end of file diff --git a/src/Cake.Common/ReleaseNotes.cs b/src/Cake.Common/ReleaseNotes.cs index adef27c75e..b02fefc893 100644 --- a/src/Cake.Common/ReleaseNotes.cs +++ b/src/Cake.Common/ReleaseNotes.cs @@ -15,6 +15,12 @@ public sealed class ReleaseNotes { private readonly List _notes; + /// + /// Gets the version. + /// + /// The version. + public SemVersion SemVersion { get; } + /// /// Gets the version. /// @@ -33,6 +39,21 @@ public sealed class ReleaseNotes /// The raw text of the Version line. public string RawVersionLine { get; } + /// + /// Initializes a new instance of the class. + /// + /// The semantic version. + /// The notes. + /// The raw text of the version line. + public ReleaseNotes(SemVersion semVersion, IEnumerable notes, string rawVersionLine) + : this( + semVersion?.AssemblyVersion ?? throw new ArgumentNullException(nameof(semVersion)), + semVersion, + notes, + rawVersionLine) + { + } + /// /// Initializes a new instance of the class. /// @@ -40,12 +61,18 @@ public sealed class ReleaseNotes /// The notes. /// The raw text of the version line. public ReleaseNotes(Version version, IEnumerable notes, string rawVersionLine) + : this( + version ?? throw new ArgumentNullException(nameof(version)), + new SemVersion(version.Major, version.Minor, version.Build), + notes, + rawVersionLine) + { + } + + private ReleaseNotes(Version version, SemVersion semVersion, IEnumerable notes, string rawVersionLine) { - if (version == null) - { - throw new ArgumentNullException(nameof(version)); - } - Version = version; + Version = version ?? throw new ArgumentNullException(nameof(version)); + SemVersion = semVersion ?? throw new ArgumentNullException(nameof(semVersion)); RawVersionLine = rawVersionLine; _notes = new List(notes ?? Enumerable.Empty()); } diff --git a/src/Cake.Common/ReleaseNotesAliases.cs b/src/Cake.Common/ReleaseNotesAliases.cs index ab7ca2a140..f98e84fd0e 100644 --- a/src/Cake.Common/ReleaseNotesAliases.cs +++ b/src/Cake.Common/ReleaseNotesAliases.cs @@ -17,6 +17,7 @@ namespace Cake.Common /// Contains functionality related to release notes. /// [CakeAliasCategory("Release Notes")] + public static class ReleaseNotesAliases { private static readonly ReleaseNotesParser _parser; diff --git a/src/Cake.Common/ReleaseNotesParser.cs b/src/Cake.Common/ReleaseNotesParser.cs index 70970e1358..44f0c84ef5 100644 --- a/src/Cake.Common/ReleaseNotesParser.cs +++ b/src/Cake.Common/ReleaseNotesParser.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. - using System; using System.Collections.Generic; using System.Linq; @@ -22,7 +21,7 @@ public sealed class ReleaseNotesParser /// public ReleaseNotesParser() { - _versionRegex = new Regex(@"([0-9]+\.)+[0-9]+"); + _versionRegex = new Regex(@"(?\d+(\s*\.\s*\d+){0,3})(?-[a-z][0-9a-z-]*)?"); } /// @@ -68,15 +67,14 @@ private IReadOnlyList ParseComplexFormat(string[] lines) break; } - // Parse header. - var versionResult = _versionRegex.Match(lines[lineIndex]); - if (!versionResult.Success) + // Create release notes. + var semVer = SemVersion.Zero; + var version = SemVersion.TryParse(lines[lineIndex], out semVer); + if (!version) { throw new CakeException("Could not parse version from release notes header."); } - // Create release notes. - var version = Version.Parse(versionResult.Value); var rawVersionLine = lines[lineIndex]; // Increase the line index. @@ -106,10 +104,10 @@ private IReadOnlyList ParseComplexFormat(string[] lines) lineIndex++; } - result.Add(new ReleaseNotes(version, notes, rawVersionLine)); + result.Add(new ReleaseNotes(semVer, notes, rawVersionLine)); } - return result.OrderByDescending(x => x.Version).ToArray(); + return result.OrderByDescending(x => x.SemVersion).ToArray(); } private IReadOnlyList ParseSimpleFormat(string[] lines) @@ -133,24 +131,22 @@ private IReadOnlyList ParseSimpleFormat(string[] lines) } // Parse header. - var versionResult = _versionRegex.Match(line); - if (!versionResult.Success) + var semVer = SemVersion.Zero; + var version = SemVersion.TryParse(lines[lineIndex], out semVer); + if (!version) { throw new CakeException("Could not parse version from release notes header."); } - - var version = Version.Parse(versionResult.Value); - // Parse the description. - line = line.Substring(versionResult.Length).Trim('-', ' '); + line = line.Substring(semVer.ToString().Length).Trim('-', ' '); // Add the release notes to the result. - result.Add(new ReleaseNotes(version, new[] { line }, line)); + result.Add(new ReleaseNotes(semVer, new[] { line }, line)); lineIndex++; } - return result.OrderByDescending(x => x.Version).ToArray(); + return result.OrderByDescending(x => x.SemVersion).ToArray(); } } } \ No newline at end of file diff --git a/src/Cake.Common/SemanticVersion.cs b/src/Cake.Common/SemanticVersion.cs new file mode 100644 index 0000000000..f97f5ef82a --- /dev/null +++ b/src/Cake.Common/SemanticVersion.cs @@ -0,0 +1,339 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Globalization; +using System.Text; +using System.Text.RegularExpressions; + +namespace Cake.Common +{ + /// + /// Class for representing semantic versions. + /// + public class SemVersion : IComparable, IComparable, IEquatable + { + /// + /// Gets the default version of a SemanticVersion. + /// + public static SemVersion Zero { get; } = new SemVersion(0, 0, 0, null, null, "0.0.0"); + + /// + /// Regex property for parsing a semantic version number. + /// + public static readonly Regex SemVerRegex = + new Regex( + @"(?0|(?:[1-9]\d*))(?:\.(?0|(?:[1-9]\d*))(?:\.(?0|(?:[1-9]\d*)))?(?:\-(?[0-9A-Z\.-]+))?(?:\+(?[0-9A-Z\.-]+))?)?", + RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase); + + /// + /// Gets the major number of the version. + /// + public int Major { get; } + + /// + /// Gets the minor number of the version. + /// + public int Minor { get; } + + /// + /// Gets the patch number of the version. + /// + public int Patch { get; } + + /// + /// Gets the prerelease of the version. + /// + public string PreRelease { get; } + + /// + /// Gets the meta of the version. + /// + public string Meta { get; } + + /// + /// Gets a value indicating whether semantic version is a prerelease or not. + /// + public bool IsPreRelease { get; } + + /// + /// Gets a value indicating whether semantic version has meta or not. + /// + public bool HasMeta { get; } + + /// + /// Gets the VersionString of the semantic version. + /// + public string VersionString { get; } + + /// + /// Gets the AssemblyVersion of the semantic version. + /// + public Version AssemblyVersion { get; } + + /// + /// Initializes a new instance of the class. + /// + /// Major number. + /// Minor number. + /// Patch number. + /// Prerelease string. + /// Meta string. + public SemVersion(int major, int minor, int patch, string preRelease = null, string meta = null) : this(major, minor, patch, preRelease, meta, null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// Major number. + /// Minor number. + /// Patch number. + /// Prerelease string. + /// Meta string. + /// The complete version number. + public SemVersion(int major, int minor, int patch, string preRelease, string meta, string versionString) + { + Major = major; + Minor = minor; + Patch = patch; + AssemblyVersion = new Version(major, minor, patch); + IsPreRelease = !string.IsNullOrEmpty(preRelease); + HasMeta = !string.IsNullOrEmpty(meta); + PreRelease = IsPreRelease ? preRelease : null; + Meta = HasMeta ? meta : null; + + if (!string.IsNullOrEmpty(versionString)) + { + VersionString = versionString; + } + else + { + var sb = new StringBuilder(); + sb.AppendFormat(CultureInfo.InvariantCulture, "{0}.{1}.{2}", Major, Minor, Patch); + + if (IsPreRelease) + { + sb.AppendFormat(CultureInfo.InvariantCulture, "-{0}", PreRelease); + } + + if (HasMeta) + { + sb.AppendFormat(CultureInfo.InvariantCulture, "+{0}", Meta); + } + + VersionString = sb.ToString(); + } + } + + /// + /// Method which tries to parse a semantic version string. + /// + /// the version that should be parsed. + /// the out parameter the parsed version should be stored in. + /// Returns a boolean indicating if the parse was successful. + public static bool TryParse(string version, + out SemVersion semVersion) + { + semVersion = Zero; + + if (string.IsNullOrEmpty(version)) + { + return false; + } + + var match = SemVerRegex.Match(version); + if (!match.Success) + { + return false; + } + + if (!int.TryParse( + match.Groups["Major"].Value, + NumberStyles.Integer, + CultureInfo.InvariantCulture, + out var major) || + !int.TryParse( + match.Groups["Minor"].Value, + NumberStyles.Integer, + CultureInfo.InvariantCulture, + out var minor) || + !int.TryParse( + match.Groups["Patch"].Value, + NumberStyles.Integer, + CultureInfo.InvariantCulture, + out var patch)) + { + return false; + } + + semVersion = new SemVersion( + major, + minor, + patch, + match.Groups["PreRelease"]?.Value, + match.Groups["Meta"]?.Value, + version); + + return true; + } + + /// + /// Checks if two SemVersion objects are equal. + /// + /// the other SemVersion want to test equality to. + /// A boolean indicating whether the objecst we're equal or not. + public bool Equals(SemVersion other) + { + return other is object + && Major == other.Major + && Minor == other.Minor + && Patch == other.Patch + && string.Equals(PreRelease, other.PreRelease, StringComparison.OrdinalIgnoreCase) + && string.Equals(Meta, other.Meta, StringComparison.OrdinalIgnoreCase); + } + + /// + /// Compares to SemVersion objects to and another. + /// + /// The SemVersion object we compare with. + /// Return 0 if the objects are identical, 1 if the version is newer and -1 if the version is older. + public int CompareTo(SemVersion other) + { + if (Equals(other)) + { + return 0; + } + + if (Major > other.Major) + { + return 1; + } + + if (Major < other.Major) + { + return -1; + } + + if (Minor > other.Minor) + { + return 1; + } + + if (Minor < other.Minor) + { + return -1; + } + + if (Patch > other.Patch) + { + return 1; + } + + if (Patch < other.Patch) + { + return -1; + } + + switch (StringComparer.InvariantCultureIgnoreCase.Compare(PreRelease, other.PreRelease)) + { + case 1: + return 1; + + case -1: + return -1; + + default: + return StringComparer.InvariantCultureIgnoreCase.Compare(Meta, other.Meta); + } + } + + /// + /// Compares to SemVersion objects to and another. + /// + /// The object we compare with. + /// Return 0 if the objects are identical, 1 if the version is newer and -1 if the version is older. + public int CompareTo(object obj) + { + return (obj is SemVersion semVersion) + ? CompareTo(semVersion) + : -1; + } + + /// + /// Equals-method for the SemVersion class. + /// + /// the other SemVersion want to test equality to. + /// A boolean indicating whether the objecst we're equal or not. + public override bool Equals(object obj) + { + return (obj is SemVersion semVersion) + && Equals(semVersion); + } + + /// + /// Method for getting the hashcode of the SemVersion object. + /// + /// The hashcode of the SemVersion object. + public override int GetHashCode() + { + unchecked + { + var hashCode = Major; + hashCode = (hashCode * 397) ^ Minor; + hashCode = (hashCode * 397) ^ Patch; + hashCode = (hashCode * 397) ^ (PreRelease != null ? StringComparer.OrdinalIgnoreCase.GetHashCode(PreRelease) : 0); + hashCode = (hashCode * 397) ^ (Meta != null ? StringComparer.OrdinalIgnoreCase.GetHashCode(Meta) : 0); + return hashCode; + } + } + + /// + /// Returns the string representation of an SemVersion object. + /// + /// The string representation of the object. + public override string ToString() + { + int[] verParts = { Major, Minor, Patch }; + string ver = string.Join(".", verParts); + return $"{ver}{(IsPreRelease ? "-" : string.Empty)}{PreRelease}{Meta}"; + } + + /// + /// The greater than-operator for the SemVersion class. + /// + /// first SemVersion. + /// second. SemVersion. + /// A value indicating if the operand1 was greater than operand2. + public static bool operator >(SemVersion operand1, SemVersion operand2) + => operand1.CompareTo(operand2) == 1; + + /// + /// The less than-operator for the SemVersion class. + /// + /// first SemVersion. + /// second. SemVersion. + /// A value indicating if the operand1 was less than operand2. + public static bool operator <(SemVersion operand1, SemVersion operand2) + => operand1.CompareTo(operand2) == -1; + + /// + /// The greater than or equal to-operator for the SemVersion class. + /// + /// first SemVersion. + /// second. SemVersion. + /// A value indicating if the operand1 was greater than or equal to operand2. + public static bool operator >=(SemVersion operand1, SemVersion operand2) + => operand1.CompareTo(operand2) >= 0; + + /// + /// The lesser than or equal to-operator for the SemVersion class. + /// + /// first SemVersion. + /// second. SemVersion. + /// A value indicating if the operand1 was lesser than or equal to operand2. + public static bool operator <=(SemVersion operand1, SemVersion operand2) + => operand1.CompareTo(operand2) <= 0; + } +} diff --git a/tests/integration/Cake.Common/ReleaseNotesAliases.cake b/tests/integration/Cake.Common/ReleaseNotesAliases.cake index d117278030..60bcfc3635 100644 --- a/tests/integration/Cake.Common/ReleaseNotesAliases.cake +++ b/tests/integration/Cake.Common/ReleaseNotesAliases.cake @@ -1,6 +1,5 @@ #load "./../utilities/xunit.cake" #load "./../utilities/paths.cake" - Task("Cake.Common.ReleaseNotesAliases.ParseAllReleaseNotes") .Does(() => { @@ -8,7 +7,7 @@ Task("Cake.Common.ReleaseNotesAliases.ParseAllReleaseNotes") var path = Paths.Resources.Combine("./Cake.Common"); var file = path.CombineWithFilePath("./ReleaseNotes.md"); var expectFirst = new ReleaseNotes( - version: new Version("0.15.2"), + version: new Version(0, 15, 2), notes: new [] { "Ensured that WiX candle definitions are enclosed in quotes", "Corrected issue with WixHeat HarvestType Out parameter" @@ -16,7 +15,7 @@ Task("Cake.Common.ReleaseNotesAliases.ParseAllReleaseNotes") rawVersionLine: "### New on 0.15.2 (Released 2016/07/29)" ); var expectLast = new ReleaseNotes( - version: new Version("0.15.1"), + version: new Version(0, 15, 1), notes: new [] { "Corrected Issues found with 0.15.0 AppVeyor updates" }, @@ -50,7 +49,7 @@ Task("Cake.Common.ReleaseNotesAliases.ParseReleaseNotes") var path = Paths.Resources.Combine("./Cake.Common"); var file = path.CombineWithFilePath("./ReleaseNotes.md"); var expect = new ReleaseNotes( - version: new Version("0.15.2"), + version: new Version(0, 15, 2), notes: new [] { "Ensured that WiX candle definitions are enclosed in quotes", "Corrected issue with WixHeat HarvestType Out parameter" @@ -68,6 +67,78 @@ Task("Cake.Common.ReleaseNotesAliases.ParseReleaseNotes") Assert.Equal(expect.Notes, result.Notes); }); +Task("Cake.Common.ReleaseNotesAliases.ParseAllReleaseNotesSemVer") + .Does(() => +{ + // Given + var path = Paths.Resources.Combine("./Cake.Common"); + var file = path.CombineWithFilePath("./ReleaseNotesSemVer.md"); + var expectFirst = new ReleaseNotes( + semVersion: new SemVersion(0, 15, 2, "alpha001"), + notes: new [] { + "Ensured that WiX candle definitions are enclosed in quotes", + "Corrected issue with WixHeat HarvestType Out parameter" + }, + rawVersionLine: "### New on 0.15.2-alpha001 (Released 2016/07/29)" + ); + var expectLast = new ReleaseNotes( + semVersion: new SemVersion(0, 15, 1, "beta001"), + notes: new [] { + "Corrected Issues found with 0.15.0 AppVeyor updates" + }, + rawVersionLine: "### New on 0.15.1-beta001 (Released 2016/07/28)" + ); + + // When + var result = ParseAllReleaseNotes(file).ToArray(); + var first = result.FirstOrDefault(); + var last = result.LastOrDefault(); + + // Then + Assert.NotNull(first); + Assert.NotNull(last); + Assert.NotEqual(first, last); + Assert.Equal(2, result.Length); + + Assert.Equal(expectFirst.Version, first.Version); + Assert.Equal(expectFirst.SemVersion, first.SemVersion); + Assert.Equal(expectFirst.RawVersionLine, first.RawVersionLine); + Assert.Equal(expectFirst.Notes, first.Notes); + + Assert.Equal(expectLast.Version, last.Version); + Assert.Equal(expectLast.SemVersion, last.SemVersion); + Assert.Equal(expectFirst.RawVersionLine, first.RawVersionLine); + Assert.Equal(expectFirst.Notes, first.Notes); +}); + +Task("Cake.Common.ReleaseNotesAliases.ParseReleaseNotesSemVer") + .Does(() => +{ + // Given + var path = Paths.Resources.Combine("./Cake.Common"); + var file = path.CombineWithFilePath("./ReleaseNotesSemVer.md"); + var expect = new ReleaseNotes( + semVersion: new SemVersion(0,15,2, "alpha001"), + notes: new [] { + "Ensured that WiX candle definitions are enclosed in quotes", + "Corrected issue with WixHeat HarvestType Out parameter" + }, + rawVersionLine: "### New on 0.15.2-alpha001 (Released 2016/07/29)" + ); + + // When + var result = ParseReleaseNotes(file); + + // Then + Assert.NotNull(result); + Assert.Equal(expect.Version, result.Version); + Assert.Equal(expect.SemVersion, result.SemVersion); + Assert.Equal(expect.RawVersionLine, result.RawVersionLine); + Assert.Equal(expect.Notes, result.Notes); +}); + Task("Cake.Common.ReleaseNotesAliases") .IsDependentOn("Cake.Common.ReleaseNotesAliases.ParseAllReleaseNotes") - .IsDependentOn("Cake.Common.ReleaseNotesAliases.ParseReleaseNotes"); \ No newline at end of file + .IsDependentOn("Cake.Common.ReleaseNotesAliases.ParseReleaseNotes") + .IsDependentOn("Cake.Common.ReleaseNotesAliases.ParseAllReleaseNotesSemVer") + .IsDependentOn("Cake.Common.ReleaseNotesAliases.ParseReleaseNotesSemVer"); \ No newline at end of file diff --git a/tests/integration/resources/Cake.Common/ReleaseNotesSemVer.md b/tests/integration/resources/Cake.Common/ReleaseNotesSemVer.md new file mode 100644 index 0000000000..c67667c5af --- /dev/null +++ b/tests/integration/resources/Cake.Common/ReleaseNotesSemVer.md @@ -0,0 +1,8 @@ +### New on 0.15.2-alpha001 (Released 2016/07/29) + +* Ensured that WiX candle definitions are enclosed in quotes +* Corrected issue with WixHeat HarvestType Out parameter + +### New on 0.15.1-beta001 (Released 2016/07/28) + +* Corrected Issues found with 0.15.0 AppVeyor updates