From 4479b908391e139082efe5249adc438ac7c51ba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Kro=CC=88ner?= Date: Sun, 24 Sep 2023 19:26:23 +0200 Subject: [PATCH 01/13] build: Bump recommended .NET version --- global.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/global.json b/global.json index 38e6f3d..b2e365e 100644 --- a/global.json +++ b/global.json @@ -1,7 +1,7 @@ { "sdk": { - "version": "7.0.100", + "version": "7.0.300", "rollForward": "latestPatch", "allowPrerelease": false } -} \ No newline at end of file +} From f7f51eab1f65d5f897d6ef315bcfdb4dd9fa66d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Kro=CC=88ner?= Date: Mon, 25 Sep 2023 15:52:37 +0200 Subject: [PATCH 02/13] test: Add new variants extension to easily check for case insensitivity --- .../Variants.spec.cs | 62 +++++++++++++++++++ .../VariantsExtensions.cs | 30 +++++++++ 2 files changed, 92 insertions(+) create mode 100644 test/ConventionalChangelog.Unit.Tests/Variants.spec.cs create mode 100644 test/ConventionalChangelog.Unit.Tests/VariantsExtensions.cs diff --git a/test/ConventionalChangelog.Unit.Tests/Variants.spec.cs b/test/ConventionalChangelog.Unit.Tests/Variants.spec.cs new file mode 100644 index 0000000..b401e0d --- /dev/null +++ b/test/ConventionalChangelog.Unit.Tests/Variants.spec.cs @@ -0,0 +1,62 @@ +using System.Diagnostics.CodeAnalysis; +using FluentAssertions; +using Xunit; + +namespace ConventionalChangelog.Unit.Tests; + +public class Variants +{ + [Fact] + [SuppressMessage("ReSharper", "StringLiteralTypo")] + public void A() + { + ((int)'a').Should().Be(97); + ((int)'A').Should().Be(65); + ((char)('z' + 1)).Should().Be('{'); + ((char)('Z' + 1)).Should().Be('['); + ((char)('a' - 1)).Should().Be('`'); + ((char)('A' - 1)).Should().Be('@'); + ('a'-'A').Should().Be(32); + + + "".CaseVariants().Should().Equal(""); + " ".CaseVariants().Should().Equal(" "); + " ".CaseVariants().Should().Equal(" "); + + "a".CaseVariants().Should().Equal("a", "A"); + "b".CaseVariants().Should().Equal("b", "B"); + "c".CaseVariants().Should().Equal("c", "C"); + "m".CaseVariants().Should().Equal("m", "M"); + "z".CaseVariants().Should().Equal("z", "Z"); + + "A".CaseVariants().Should().Equal("a", "A"); + "B".CaseVariants().Should().Equal("b", "B"); + "C".CaseVariants().Should().Equal("c", "C"); + "M".CaseVariants().Should().Equal("m", "M"); + "Z".CaseVariants().Should().Equal("z", "Z"); + + "0".CaseVariants().Should().Equal("0"); + "{".CaseVariants().Should().Equal("{"); + "[".CaseVariants().Should().Equal("["); + "`".CaseVariants().Should().Equal("`"); + "@".CaseVariants().Should().Equal("@"); + + "a0".CaseVariants().Should().Equal("a0", "A0"); + "aa".CaseVariants().Should().Equal("aa", "aA", "Aa", "AA"); + "aaa".CaseVariants().Should().Equal("aaa", "aAa", "AaA", "AAA"); + "aaaa".CaseVariants().Should().Equal("aaaa", "aAaA", "AaAa", "AAAA"); + + "A0".CaseVariants().Should().Equal("a0", "A0"); + "AA".CaseVariants().Should().Equal("aa", "aA", "Aa", "AA"); + "AAA".CaseVariants().Should().Equal("aaa", "aAa", "AaA", "AAA"); + "AAAA".CaseVariants().Should().Equal("aaaa", "aAaA", "AaAa", "AAAA"); + + "abcdefghijklmnopqrstuvwxyz".CaseVariants().Should().Equal( + "abcdefghijklmnopqrstuvwxyz", + "aBcDeFgHiJkLmNoPqRsTuVwXyZ", + "AbCdEfGhIjKlMnOpQrStUvWxYz", + "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + } + + +} diff --git a/test/ConventionalChangelog.Unit.Tests/VariantsExtensions.cs b/test/ConventionalChangelog.Unit.Tests/VariantsExtensions.cs new file mode 100644 index 0000000..0d4dc43 --- /dev/null +++ b/test/ConventionalChangelog.Unit.Tests/VariantsExtensions.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace ConventionalChangelog.Unit.Tests; + +internal static class VariantsExtensions +{ + public static IEnumerable CaseVariants(this string original) => AllVariants(original).Distinct(); + + private static IEnumerable AllVariants(string original) + { + yield return original.ToLower(); + yield return original.To(LowerUpper); + yield return original.To(UpperLower); + yield return original.ToUpper(); + } + + private static string To(this string original, Func rule) => new(original.Select(rule).ToArray()); + + private static char UpperLower(char @char, int index) => LowerOrUpperIfIndex(@char, index, 0); + private static char LowerUpper(char @char, int index) => LowerOrUpperIfIndex(@char, index, 1); + + private static char LowerOrUpperIfIndex(char @char, int index, int offset) + { + return index % 2 == offset + ? char.ToUpper(@char) + : char.ToLower(@char); + } +} From 5fe0d69de70e593d8c87492426e8946a7435fc42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Kro=CC=88ner?= Date: Mon, 25 Sep 2023 18:37:32 +0200 Subject: [PATCH 03/13] refactor: Introduce case variant attribute to generate string variants --- ...onventional_commits_with_fix_up_commits.cs | 18 ++++++++------- .../Variants.spec.cs | 22 ++++++++++++++++--- .../VariantsExtensions.cs | 19 +++++++++++++++- 3 files changed, 47 insertions(+), 12 deletions(-) diff --git a/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_fix_up_commits.cs b/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_fix_up_commits.cs index 01bdeb9..ec45342 100644 --- a/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_fix_up_commits.cs +++ b/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_fix_up_commits.cs @@ -1,5 +1,6 @@ using FluentAssertions; using Xunit; +using Base = ConventionalChangelog.Unit.Tests.Changelog_specs.A_changelog_from_changelog_relevant_conventional_commits; namespace ConventionalChangelog.Unit.Tests.Changelog_specs; @@ -7,10 +8,12 @@ public partial class A_changelog_from_changelog_relevant_conventional_commits { public class With_fix_up_commits { - private const string DefaultFixUpToken = @"Fixes"; + private const string DefaultFixUpToken = "Fixes"; + private const string LegacyFixUpToken = "FixUp"; private readonly Commit _target; private readonly Commit _fixUp; + public With_fix_up_commits() { _target = CommitTypeFor.Feature.CommitWithDescription(1); @@ -26,11 +29,8 @@ public void when_the_fixed_up_commit_is_part_of_the_changelog_excludes_the_fix_u } [Theory] - [InlineData(DefaultFixUpToken)] - [InlineData(@"fixup")] - [InlineData("FixUp")] - [InlineData("fIXuP")] - [InlineData(@"fIXES")] + [CaseVariantData(DefaultFixUpToken)] + [CaseVariantData(LegacyFixUpToken)] public void recognizes_fix_up_commits_by_the(string footer) { var fixUp = CommitTypeFor.Feature.CommitWithDescription(2).WithFooter(footer, _target.Hash); @@ -40,7 +40,8 @@ public void recognizes_fix_up_commits_by_the(string footer) } [Fact] - public void when_a_fixed_up_fix_up_commit_is_part_of_the_changelog_excludes_the_fix_up_commit_from_the_changelog() + public void + when_a_fixed_up_fix_up_commit_is_part_of_the_changelog_excludes_the_fix_up_commit_from_the_changelog() { var fixUp2 = CommitTypeFor.Feature.CommitWithDescription(3).WithFooter(DefaultFixUpToken, _fixUp.Hash); @@ -50,7 +51,8 @@ public void when_a_fixed_up_fix_up_commit_is_part_of_the_changelog_excludes_the_ } [Fact] - public void when_multiple_fix_up_commits_target_a_single_commit_that_is_part_of_the_changelog_excludes_all_the_fix_up_commits_from_the_changelog() + public void + when_multiple_fix_up_commits_target_a_single_commit_that_is_part_of_the_changelog_excludes_all_the_fix_up_commits_from_the_changelog() { var fixUp2 = CommitTypeFor.Feature.CommitWithDescription(3).WithFooter(DefaultFixUpToken, _target.Hash); diff --git a/test/ConventionalChangelog.Unit.Tests/Variants.spec.cs b/test/ConventionalChangelog.Unit.Tests/Variants.spec.cs index b401e0d..8f2dcb5 100644 --- a/test/ConventionalChangelog.Unit.Tests/Variants.spec.cs +++ b/test/ConventionalChangelog.Unit.Tests/Variants.spec.cs @@ -1,14 +1,20 @@ +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using FluentAssertions; using Xunit; namespace ConventionalChangelog.Unit.Tests; -public class Variants +public class The_case_variants_attribute { + private static IEnumerable AttributeCasesFrom(string source) + { + return new CaseVariantDataAttribute(source).GetData(default!); + } + [Fact] [SuppressMessage("ReSharper", "StringLiteralTypo")] - public void A() + public void Generates_variants_of_original_string_with_upper_lower_and_mixed_casing() { ((int)'a').Should().Be(97); ((int)'A').Should().Be(65); @@ -58,5 +64,15 @@ public void A() "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); } - + [Fact] + [SuppressMessage("ReSharper", "StringLiteralTypo")] + public void Generates_xunit_cases_of_original_string_with_upper_lower_and_mixed_casing() + { + AttributeCasesFrom("test").Should().SatisfyRespectively( + o => o.Should().ContainSingle().Which.Should().Be("test"), + o => o.Should().ContainSingle().Which.Should().Be("tEsT"), + o => o.Should().ContainSingle().Which.Should().Be("TeSt"), + o => o.Should().ContainSingle().Which.Should().Be("TEST") + ); + } } diff --git a/test/ConventionalChangelog.Unit.Tests/VariantsExtensions.cs b/test/ConventionalChangelog.Unit.Tests/VariantsExtensions.cs index 0d4dc43..52892d6 100644 --- a/test/ConventionalChangelog.Unit.Tests/VariantsExtensions.cs +++ b/test/ConventionalChangelog.Unit.Tests/VariantsExtensions.cs @@ -1,11 +1,28 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; +using Xunit.Sdk; namespace ConventionalChangelog.Unit.Tests; -internal static class VariantsExtensions + +internal class CaseVariantDataAttribute: DataAttribute { + private readonly string _source; + + public CaseVariantDataAttribute(string source) => _source = source; + + public override IEnumerable GetData(MethodInfo testMethod) => _source.Cases2(); +} + +internal static class VariantsExtensions2 +{ + public static IEnumerable Cases2(this string source) + { + return source.CaseVariants().Select(x => new object[] { x }); + } + public static IEnumerable CaseVariants(this string original) => AllVariants(original).Distinct(); private static IEnumerable AllVariants(string original) From c68ab11bd7733e90c8e36b4e09810e48c0ded7c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Kro=CC=88ner?= Date: Mon, 25 Sep 2023 18:37:50 +0200 Subject: [PATCH 04/13] refactor: Remove experimentation tests --- test/ConventionalChangelog.Unit.Tests/Variants.spec.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/test/ConventionalChangelog.Unit.Tests/Variants.spec.cs b/test/ConventionalChangelog.Unit.Tests/Variants.spec.cs index 8f2dcb5..d46106a 100644 --- a/test/ConventionalChangelog.Unit.Tests/Variants.spec.cs +++ b/test/ConventionalChangelog.Unit.Tests/Variants.spec.cs @@ -16,15 +16,6 @@ private static IEnumerable AttributeCasesFrom(string source) [SuppressMessage("ReSharper", "StringLiteralTypo")] public void Generates_variants_of_original_string_with_upper_lower_and_mixed_casing() { - ((int)'a').Should().Be(97); - ((int)'A').Should().Be(65); - ((char)('z' + 1)).Should().Be('{'); - ((char)('Z' + 1)).Should().Be('['); - ((char)('a' - 1)).Should().Be('`'); - ((char)('A' - 1)).Should().Be('@'); - ('a'-'A').Should().Be(32); - - "".CaseVariants().Should().Equal(""); " ".CaseVariants().Should().Equal(" "); " ".CaseVariants().Should().Equal(" "); From 3936743244877f5ce8a54e255dcaec3cd4923c61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Kro=CC=88ner?= Date: Mon, 25 Sep 2023 19:13:16 +0200 Subject: [PATCH 05/13] test: Add original casing to generated test cases --- .../The_case_variants_attribute.spec.cs | 76 +++++++++++++++++++ .../Variants.spec.cs | 69 ----------------- .../VariantsExtensions.cs | 11 +-- 3 files changed, 82 insertions(+), 74 deletions(-) create mode 100644 test/ConventionalChangelog.Unit.Tests/The_case_variants_attribute.spec.cs delete mode 100644 test/ConventionalChangelog.Unit.Tests/Variants.spec.cs diff --git a/test/ConventionalChangelog.Unit.Tests/The_case_variants_attribute.spec.cs b/test/ConventionalChangelog.Unit.Tests/The_case_variants_attribute.spec.cs new file mode 100644 index 0000000..8b44a5d --- /dev/null +++ b/test/ConventionalChangelog.Unit.Tests/The_case_variants_attribute.spec.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using FluentAssertions; +using Xunit; + +namespace ConventionalChangelog.Unit.Tests; + +public class The_case_variants_attribute +{ + private static IEnumerable AttributeCasesFrom(string source) + { + return new CaseVariantDataAttribute(source).GetData(default!); + } + + [Theory] + [InlineData("")] + [InlineData(" ")] + [InlineData(" ")] + [InlineData("0")] + [InlineData("1234567890")] + [InlineData("{")] + [InlineData("[")] + [InlineData("`")] + [InlineData("@")] + public void generates_xunit_test_cases_with_the_given_strings_for_numbers_and_special_characters(string input) + { + AttributeCasesFrom(input).Should() + .ContainSingle().Which.Should() + .ContainSingle().Which.Should().Be(input); + } + + [Theory, SuppressMessage("ReSharper", "StringLiteralTypo")] + [InlineData("a", "a", "A")] + [InlineData("b", "b", "B")] + [InlineData("m", "m", "M")] + [InlineData("z", "z", "Z")] + [InlineData("A", "a", "A")] + [InlineData("B", "b", "B")] + [InlineData("M", "m", "M")] + [InlineData("Z", "z", "Z")] + [InlineData("a0", "a0", "A0")] + [InlineData("aa", "aa", "aA", "Aa", "AA")] + [InlineData("aaa", "aaa", "aAa", "AaA", "AAA")] + [InlineData("aaaa", "aaaa", "aAaA", "AaAa", "AAAA")] + + [InlineData("A0", "a0", "A0")] + [InlineData("AA", "aa", "aA", "Aa", "AA")] + [InlineData("AAA", "aaa", "aAa", "AaA", "AAA")] + [InlineData("AAAA", "aaaa", "aAaA", "AaAa", "AAAA")] + + [InlineData("abcdefg", "abcdefg", "aBcDeFg", "AbCdEfG", "ABCDEFG")] + [InlineData("test", "test", "tEsT", "TeSt", "TEST")] + public void generates_xunit_test_cases_with_strings_of_lower_mixed_and_upper_casing( + string input, params string[] expected) + { + AttributeCasesFrom(input).Should() + .SatisfyRespectively(TestCases(expected)); + } + + [Theory, SuppressMessage("ReSharper", "StringLiteralTypo")] + [InlineData("AbcDef", "AbcDef", "abcdef", "aBcDeF", "AbCdEf", "ABCDEF")] + public void generates_xunit_test_cases_including_the_original_casing_if_not_contained_in_generated_ones( + string input, params string[] expected) + { + AttributeCasesFrom(input).Should() + .SatisfyRespectively(TestCases(expected)); + } + + private static IEnumerable> TestCases(IEnumerable cases) => + cases.Select(TestCase); + + private static Action TestCase(string arg) => + o => o.Should().Equal(arg); +} diff --git a/test/ConventionalChangelog.Unit.Tests/Variants.spec.cs b/test/ConventionalChangelog.Unit.Tests/Variants.spec.cs deleted file mode 100644 index d46106a..0000000 --- a/test/ConventionalChangelog.Unit.Tests/Variants.spec.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using FluentAssertions; -using Xunit; - -namespace ConventionalChangelog.Unit.Tests; - -public class The_case_variants_attribute -{ - private static IEnumerable AttributeCasesFrom(string source) - { - return new CaseVariantDataAttribute(source).GetData(default!); - } - - [Fact] - [SuppressMessage("ReSharper", "StringLiteralTypo")] - public void Generates_variants_of_original_string_with_upper_lower_and_mixed_casing() - { - "".CaseVariants().Should().Equal(""); - " ".CaseVariants().Should().Equal(" "); - " ".CaseVariants().Should().Equal(" "); - - "a".CaseVariants().Should().Equal("a", "A"); - "b".CaseVariants().Should().Equal("b", "B"); - "c".CaseVariants().Should().Equal("c", "C"); - "m".CaseVariants().Should().Equal("m", "M"); - "z".CaseVariants().Should().Equal("z", "Z"); - - "A".CaseVariants().Should().Equal("a", "A"); - "B".CaseVariants().Should().Equal("b", "B"); - "C".CaseVariants().Should().Equal("c", "C"); - "M".CaseVariants().Should().Equal("m", "M"); - "Z".CaseVariants().Should().Equal("z", "Z"); - - "0".CaseVariants().Should().Equal("0"); - "{".CaseVariants().Should().Equal("{"); - "[".CaseVariants().Should().Equal("["); - "`".CaseVariants().Should().Equal("`"); - "@".CaseVariants().Should().Equal("@"); - - "a0".CaseVariants().Should().Equal("a0", "A0"); - "aa".CaseVariants().Should().Equal("aa", "aA", "Aa", "AA"); - "aaa".CaseVariants().Should().Equal("aaa", "aAa", "AaA", "AAA"); - "aaaa".CaseVariants().Should().Equal("aaaa", "aAaA", "AaAa", "AAAA"); - - "A0".CaseVariants().Should().Equal("a0", "A0"); - "AA".CaseVariants().Should().Equal("aa", "aA", "Aa", "AA"); - "AAA".CaseVariants().Should().Equal("aaa", "aAa", "AaA", "AAA"); - "AAAA".CaseVariants().Should().Equal("aaaa", "aAaA", "AaAa", "AAAA"); - - "abcdefghijklmnopqrstuvwxyz".CaseVariants().Should().Equal( - "abcdefghijklmnopqrstuvwxyz", - "aBcDeFgHiJkLmNoPqRsTuVwXyZ", - "AbCdEfGhIjKlMnOpQrStUvWxYz", - "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); - } - - [Fact] - [SuppressMessage("ReSharper", "StringLiteralTypo")] - public void Generates_xunit_cases_of_original_string_with_upper_lower_and_mixed_casing() - { - AttributeCasesFrom("test").Should().SatisfyRespectively( - o => o.Should().ContainSingle().Which.Should().Be("test"), - o => o.Should().ContainSingle().Which.Should().Be("tEsT"), - o => o.Should().ContainSingle().Which.Should().Be("TeSt"), - o => o.Should().ContainSingle().Which.Should().Be("TEST") - ); - } -} diff --git a/test/ConventionalChangelog.Unit.Tests/VariantsExtensions.cs b/test/ConventionalChangelog.Unit.Tests/VariantsExtensions.cs index 52892d6..16e704b 100644 --- a/test/ConventionalChangelog.Unit.Tests/VariantsExtensions.cs +++ b/test/ConventionalChangelog.Unit.Tests/VariantsExtensions.cs @@ -13,17 +13,18 @@ internal class CaseVariantDataAttribute: DataAttribute public CaseVariantDataAttribute(string source) => _source = source; - public override IEnumerable GetData(MethodInfo testMethod) => _source.Cases2(); + public override IEnumerable GetData(MethodInfo testMethod) => _source.TestCases(); } -internal static class VariantsExtensions2 +internal static class VariantsExtensions { - public static IEnumerable Cases2(this string source) + public static IEnumerable TestCases(this string source) { - return source.CaseVariants().Select(x => new object[] { x }); + return CaseVariantsFrom(source).Select(x => new object[] { x }); } - public static IEnumerable CaseVariants(this string original) => AllVariants(original).Distinct(); + private static IEnumerable CaseVariantsFrom(string original) => + AllVariants(original).Reverse().Append(original).Distinct().Reverse(); private static IEnumerable AllVariants(string original) { From de1240da67af44f18f8d4c6b3220ba51b6fead1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Kro=CC=88ner?= Date: Mon, 25 Sep 2023 19:15:57 +0200 Subject: [PATCH 06/13] refactor: Use case variant data attribute for overrides and reverts --- ...onventional_commits_with_overriding_commits.cs | 15 ++++++--------- ...conventional_commits_with_reverting_commits.cs | 8 ++------ 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_overriding_commits.cs b/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_overriding_commits.cs index 63de4a6..d86ac31 100644 --- a/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_overriding_commits.cs +++ b/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_overriding_commits.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using FluentAssertions; using Xunit; @@ -7,7 +8,7 @@ public partial class A_changelog_from_changelog_relevant_conventional_commits { public class With_overriding_commits { - private const string DefaultOverrideToken = @"Overrides"; + private const string DefaultOverrideToken = "Overrides"; private readonly Commit _overridden; private readonly Commit _overriding; @@ -59,11 +60,7 @@ public void when_multiple_overriding_commits_target_a_single_commit_that_is_part } [Theory] - [InlineData(DefaultOverrideToken)] - [InlineData(@"override")] - [InlineData("overrides")] - [InlineData("Override")] - [InlineData(@"oVERRIDES")] + [CaseVariantData(DefaultOverrideToken)] public void recognizes_overriding_commits_by_the(string footer) { var overridingOverriding = CommitTypeFor.Feature.CommitWithDescription(2).WithFooter(footer, _overridden.Hash); @@ -72,9 +69,9 @@ public void recognizes_overriding_commits_by_the(string footer) changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 2)); } - [Theory] - [InlineData(@"hoverride")] - [InlineData(@"coverride")] + [Theory, SuppressMessage("ReSharper", "StringLiteralTypo")] + [InlineData("hoverride")] + [InlineData("coverride")] [InlineData("overwrite")] [InlineData("overrider")] public void does_not_commits_as_overriding_if_they_contain_(string footer) diff --git a/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_reverting_commits.cs b/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_reverting_commits.cs index 684c9d4..2936d4c 100644 --- a/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_reverting_commits.cs +++ b/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_reverting_commits.cs @@ -7,7 +7,7 @@ public partial class A_changelog_from_changelog_relevant_conventional_commits { public class With_reverting_commits { - private const string DefaultRevertToken = @"Reverts"; + private const string DefaultRevertToken = "Reverts"; private readonly Commit _reverted; private readonly Commit _reverting; @@ -61,11 +61,7 @@ public void when_multiple_reverting_commits_target_a_single_commit_that_is_part_ } [Theory] - [InlineData(DefaultRevertToken)] - [InlineData(@"revert")] - [InlineData("reverts")] - [InlineData("Revert")] - [InlineData(@"rEVERTS")] + [CaseVariantData(DefaultRevertToken)] public void recognizes_reverting_commits_by_the(string footer) { var reverting = CommitTypeFor.Feature.CommitWithDescription(2).WithFooter(footer, _reverted.Hash); From 8e629b49f691c78d6f6139189af06b5832bfb346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Kro=CC=88ner?= Date: Mon, 25 Sep 2023 19:21:37 +0200 Subject: [PATCH 07/13] refactor: Replace all references to legacy 'fixup' token with 'Fixes' --- ...onventional_commits_with_fix_up_commits.cs | 74 ------------------- ...onventional_commits_with_fixing_commits.cs | 73 ++++++++++++++++++ .../Integration/Git_specs.cs | 6 +- 3 files changed, 76 insertions(+), 77 deletions(-) delete mode 100644 test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_fix_up_commits.cs create mode 100644 test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_fixing_commits.cs diff --git a/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_fix_up_commits.cs b/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_fix_up_commits.cs deleted file mode 100644 index ec45342..0000000 --- a/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_fix_up_commits.cs +++ /dev/null @@ -1,74 +0,0 @@ -using FluentAssertions; -using Xunit; -using Base = ConventionalChangelog.Unit.Tests.Changelog_specs.A_changelog_from_changelog_relevant_conventional_commits; - -namespace ConventionalChangelog.Unit.Tests.Changelog_specs; - -public partial class A_changelog_from_changelog_relevant_conventional_commits -{ - public class With_fix_up_commits - { - private const string DefaultFixUpToken = "Fixes"; - private const string LegacyFixUpToken = "FixUp"; - private readonly Commit _target; - private readonly Commit _fixUp; - - - public With_fix_up_commits() - { - _target = CommitTypeFor.Feature.CommitWithDescription(1); - _fixUp = CommitTypeFor.Feature.CommitWithDescription(2).WithFooter(DefaultFixUpToken, _target.Hash); - } - - [Fact] - public void when_the_fixed_up_commit_is_part_of_the_changelog_excludes_the_fix_up_commit_from_the_changelog() - { - var changelog = Changelog.From(_fixUp, _target); - - changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 1)); - } - - [Theory] - [CaseVariantData(DefaultFixUpToken)] - [CaseVariantData(LegacyFixUpToken)] - public void recognizes_fix_up_commits_by_the(string footer) - { - var fixUp = CommitTypeFor.Feature.CommitWithDescription(2).WithFooter(footer, _target.Hash); - var changelog = Changelog.From(fixUp, _target); - - changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 1)); - } - - [Fact] - public void - when_a_fixed_up_fix_up_commit_is_part_of_the_changelog_excludes_the_fix_up_commit_from_the_changelog() - { - var fixUp2 = CommitTypeFor.Feature.CommitWithDescription(3).WithFooter(DefaultFixUpToken, _fixUp.Hash); - - var changelog = Changelog.From(fixUp2, _fixUp, _target); - - changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 1)); - } - - [Fact] - public void - when_multiple_fix_up_commits_target_a_single_commit_that_is_part_of_the_changelog_excludes_all_the_fix_up_commits_from_the_changelog() - { - var fixUp2 = CommitTypeFor.Feature.CommitWithDescription(3).WithFooter(DefaultFixUpToken, _target.Hash); - - var changelog = Changelog.From(fixUp2, _fixUp, _target); - - changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 1)); - } - - [Fact] - public void when_the_fixed_up_commit_is_not_part_of_the_changelog_includes_fix_up_commit_in_the_changelog() - { - var fixUp2 = CommitTypeFor.Feature.CommitWithDescription(3).WithFooter(DefaultFixUpToken, "randomHash"); - - var changelog = Changelog.From(fixUp2, _fixUp, _target); - - changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 3, 1)); - } - } -} diff --git a/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_fixing_commits.cs b/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_fixing_commits.cs new file mode 100644 index 0000000..1eb1049 --- /dev/null +++ b/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_fixing_commits.cs @@ -0,0 +1,73 @@ +using FluentAssertions; +using Xunit; +using Base = ConventionalChangelog.Unit.Tests.Changelog_specs.A_changelog_from_changelog_relevant_conventional_commits; + +namespace ConventionalChangelog.Unit.Tests.Changelog_specs; + +public partial class A_changelog_from_changelog_relevant_conventional_commits +{ + public class With_fixing_commits + { + private const string DefaultFixToken = "Fixes"; + private const string LegacyFixToken = "FixUp"; + private readonly Commit _target; + private readonly Commit _fixing; + + public With_fixing_commits() + { + _target = CommitTypeFor.Feature.CommitWithDescription(1); + _fixing = CommitTypeFor.Feature.CommitWithDescription(2).WithFooter(DefaultFixToken, _target.Hash); + } + + [Fact] + public void when_the_fixed_commit_is_part_of_the_changelog_excludes_the_fixing_commit_from_the_changelog() + { + var changelog = Changelog.From(_fixing, _target); + + changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 1)); + } + + [Theory] + [CaseVariantData(DefaultFixToken)] + [CaseVariantData(LegacyFixToken)] + public void recognizes_fixing_commits_by_the(string footer) + { + var fixing = CommitTypeFor.Feature.CommitWithDescription(2).WithFooter(footer, _target.Hash); + var changelog = Changelog.From(fixing, _target); + + changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 1)); + } + + [Fact] + public void + when_a_fixed_fixing_commit_is_part_of_the_changelog_excludes_the_fixing_commit_from_the_changelog() + { + var fixing2 = CommitTypeFor.Feature.CommitWithDescription(3).WithFooter(DefaultFixToken, _fixing.Hash); + + var changelog = Changelog.From(fixing2, _fixing, _target); + + changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 1)); + } + + [Fact] + public void + when_multiple_fixing_commits_target_a_single_commit_that_is_part_of_the_changelog_excludes_all_the_fixing_commits_from_the_changelog() + { + var fixing2 = CommitTypeFor.Feature.CommitWithDescription(3).WithFooter(DefaultFixToken, _target.Hash); + + var changelog = Changelog.From(fixing2, _fixing, _target); + + changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 1)); + } + + [Fact] + public void when_the_fixed_commit_is_not_part_of_the_changelog_includes_fixing_commit_in_the_changelog() + { + var fixing2 = CommitTypeFor.Feature.CommitWithDescription(3).WithFooter(DefaultFixToken, "randomHash"); + + var changelog = Changelog.From(fixing2, _fixing, _target); + + changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 3, 1)); + } + } +} diff --git a/test/ConventionalChangelog.Unit.Tests/Integration/Git_specs.cs b/test/ConventionalChangelog.Unit.Tests/Integration/Git_specs.cs index 16ff139..aa9d139 100644 --- a/test/ConventionalChangelog.Unit.Tests/Integration/Git_specs.cs +++ b/test/ConventionalChangelog.Unit.Tests/Integration/Git_specs.cs @@ -100,7 +100,7 @@ public void Changelog_from_conventional_commits_and_a_multiple_tags_on_same_comm public void Changelog_from_conventional_commits_with_fix_up_commits_excludes_those_fix_ups_with_their_target_in_the_changelog() { var after = Repository.Commit(Feature.CommitWithDescription(1)); - Repository.Commit(Feature.CommitWithDescription(2).WithFooter(@"fixup", after.Sha)); + Repository.Commit(Feature.CommitWithDescription(2).WithFooter("Fixes", after.Sha)); Changelog.FromRepository(Repository.Path()) .Should().Be(A.Changelog.WithGroup(Feature, 1)); @@ -113,8 +113,8 @@ public void Changelog_from_conventional_commits_with_fix_up_commits_excludes_tho Repository.Commit(Feature, "Multi-tagged commit").Tag("v1.0.0"); var after = Repository.Commit(Feature.CommitWithDescription(1)); - Repository.Commit(Feature.CommitWithDescription(2).WithFooter(@"fixup", after.Sha)); - Repository.Commit(Feature.CommitWithDescription(3).WithFooter(@"fixup", before.Sha)); + Repository.Commit(Feature.CommitWithDescription(2).WithFooter("Fixes", after.Sha)); + Repository.Commit(Feature.CommitWithDescription(3).WithFooter("Fixes", before.Sha)); Changelog.FromRepository(Repository.Path()) .Should().Be(A.Changelog.WithGroup(Feature, 3, 1)); From f5abd5f8e080fa71d92b889f3a041ac77370a904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Kro=CC=88ner?= Date: Mon, 25 Sep 2023 19:28:00 +0200 Subject: [PATCH 08/13] feat: Add 'Enhances' as alias for 'Fixes' --- src/ConventionalChangelog/MessageLinq.cs | 2 +- ...angelog_relevant_conventional_commits_with_fixing_commits.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ConventionalChangelog/MessageLinq.cs b/src/ConventionalChangelog/MessageLinq.cs index ad1f8d8..3fd88b7 100644 --- a/src/ConventionalChangelog/MessageLinq.cs +++ b/src/ConventionalChangelog/MessageLinq.cs @@ -10,7 +10,7 @@ internal static class MessageLinq private static readonly Strategy[] Strategies = { - new("fix(es|up)", true, true, true), + new("fix(es|up)|enhances", true, true, true), new("reverts?", false, false, true), new("overrides?", false, true, false), }; diff --git a/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_fixing_commits.cs b/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_fixing_commits.cs index 1eb1049..3b8a9f9 100644 --- a/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_fixing_commits.cs +++ b/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_fixing_commits.cs @@ -10,6 +10,7 @@ public class With_fixing_commits { private const string DefaultFixToken = "Fixes"; private const string LegacyFixToken = "FixUp"; + private const string AlternativeFixToken = "Enhances"; private readonly Commit _target; private readonly Commit _fixing; @@ -30,6 +31,7 @@ public void when_the_fixed_commit_is_part_of_the_changelog_excludes_the_fixing_c [Theory] [CaseVariantData(DefaultFixToken)] [CaseVariantData(LegacyFixToken)] + [CaseVariantData(AlternativeFixToken)] public void recognizes_fixing_commits_by_the(string footer) { var fixing = CommitTypeFor.Feature.CommitWithDescription(2).WithFooter(footer, _target.Hash); From 57650f071efa3714a29cec23240776bba2fcbd65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Kro=CC=88ner?= Date: Mon, 25 Sep 2023 19:58:53 +0200 Subject: [PATCH 09/13] test: Enable ordering of changelog chronologically --- src/ConventionalChangelog/Changelog.cs | 18 +++++++++++++++--- src/ConventionalChangelog/ChangelogOrder.cs | 7 +++++++ .../Integration/Git_specs.cs | 13 ++++++++++++- 3 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 src/ConventionalChangelog/ChangelogOrder.cs diff --git a/src/ConventionalChangelog/Changelog.cs b/src/ConventionalChangelog/Changelog.cs index 49e999d..8e04b51 100644 --- a/src/ConventionalChangelog/Changelog.cs +++ b/src/ConventionalChangelog/Changelog.cs @@ -1,6 +1,7 @@ using System.Text.RegularExpressions; using ConventionalChangelog.Conventional; using LibGit2Sharp; +using static ConventionalChangelog.ChangelogOrder; using static ConventionalChangelog.Configuration; namespace ConventionalChangelog; @@ -9,6 +10,18 @@ public static class Changelog { public static string From(params Commit[] messages) => From(messages.Select(CommitMessage.Parse)); + + private static string From(Commit[] messages, ChangelogOrder order) + { + if (order == NewestToOldest) return From(messages); + return messages.Select(CommitMessage.Parse) + .Reduce() + .SelectMany(LogEntries) + .Reverse() + .OrderBy(x => x.Type, Comparer) + .Aggregate(new LogAggregate(), Add).ToString(); + } + private static string From(IEnumerable messages) { return messages @@ -29,14 +42,13 @@ private static IEnumerable LogEntries(CommitMessage commitMessage) yield return new LogEntry(commitMessage.Type, commitMessage.Description); } - public static string FromRepository(string path) + public static string FromRepository(string path, ChangelogOrder order = NewestToOldest) { using var repo = new Repository(path); var dict = repo.Tags.GroupBy(x => x.Target).ToDictionary(x => x.Key, x => x.ToList()); var tag = (object)null!; - var filter0 = new CommitFilter { SortBy = CommitSortStrategies.Topological, @@ -58,7 +70,7 @@ public static string FromRepository(string path) ExcludeReachableFrom = tag, }; - return From(repo.Commits.QueryBy(filter).Select(AsCommit).ToArray()); + return From(repo.Commits.QueryBy(filter).Select(AsCommit).ToArray(), order); } private static Commit AsCommit(LibGit2Sharp.Commit c) => new(c.Message, c.Sha); diff --git a/src/ConventionalChangelog/ChangelogOrder.cs b/src/ConventionalChangelog/ChangelogOrder.cs new file mode 100644 index 0000000..510d4c8 --- /dev/null +++ b/src/ConventionalChangelog/ChangelogOrder.cs @@ -0,0 +1,7 @@ +namespace ConventionalChangelog; + +public enum ChangelogOrder +{ + NewestToOldest, + OldestToNewest, +} diff --git a/test/ConventionalChangelog.Unit.Tests/Integration/Git_specs.cs b/test/ConventionalChangelog.Unit.Tests/Integration/Git_specs.cs index aa9d139..8ea494c 100644 --- a/test/ConventionalChangelog.Unit.Tests/Integration/Git_specs.cs +++ b/test/ConventionalChangelog.Unit.Tests/Integration/Git_specs.cs @@ -29,7 +29,7 @@ public void A_repository_with_conventional_commits_produces_changelog_with_all_c } [Fact] - public void Changelog_from_only_conventional_commits_contains_messages_from_newest_to_oldest_commit() + public void Changelog_from_only_conventional_commits_contains_messages_by_default_from_newest_to_oldest_commit() { 3.Times(i => Repository.Commit(Feature, i)); @@ -37,6 +37,17 @@ public void Changelog_from_only_conventional_commits_contains_messages_from_newe .Should().Be(A.Changelog.WithGroup(Feature, 2, 1, 0)); } + [Theory] + [InlineData(ChangelogOrder.NewestToOldest, new[]{2,1,0})] + [InlineData(ChangelogOrder.OldestToNewest, new[]{0,1,2})] + public void Changelog_from_only_conventional_commits_contains_messages_in_requested_order(ChangelogOrder order, int[] commits) + { + 3.Times(i => Repository.Commit(Feature, i)); + + Changelog.FromRepository(Repository.Path(), order) + .Should().Be(A.Changelog.WithGroup(Feature, commits)); + } + [Theory] [InlineData("0.0.4")] [InlineData("1.2.3")] From 2550fe36f37ae3f99e293fb07eab8df2e2dfce55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Kro=CC=88ner?= Date: Mon, 25 Sep 2023 20:17:52 +0200 Subject: [PATCH 10/13] refactor: Reduce test specificity in Changelog public interface BREAKING-CHANGE: The 'From(params Commit[] messages)' method is no longer available to make space for the changelog order parameter. --- src/ConventionalChangelog/Changelog.cs | 22 +++++-------------- test/ConventionalChangelog.Unit.Tests/A.cs | 4 ++++ .../Changelog_specs/A_changelog_from.cs | 8 +++---- ...changelog_relevant_conventional_commits.cs | 6 ++--- ...nventional_commits_with_breaking_change.cs | 8 +++---- ...onventional_commits_with_fixing_commits.cs | 10 ++++----- ...ntional_commits_with_overriding_commits.cs | 14 ++++++------ ...entional_commits_with_reverting_commits.cs | 12 +++++----- 8 files changed, 39 insertions(+), 45 deletions(-) diff --git a/src/ConventionalChangelog/Changelog.cs b/src/ConventionalChangelog/Changelog.cs index 8e04b51..a6b9020 100644 --- a/src/ConventionalChangelog/Changelog.cs +++ b/src/ConventionalChangelog/Changelog.cs @@ -8,25 +8,15 @@ namespace ConventionalChangelog; public static class Changelog { - public static string From(params Commit[] messages) => From(messages.Select(CommitMessage.Parse)); - - - private static string From(Commit[] messages, ChangelogOrder order) + public static string From(IEnumerable messages, ChangelogOrder order) { - if (order == NewestToOldest) return From(messages); - return messages.Select(CommitMessage.Parse) + var logEntries = messages.Select(CommitMessage.Parse) .Reduce() - .SelectMany(LogEntries) - .Reverse() - .OrderBy(x => x.Type, Comparer) - .Aggregate(new LogAggregate(), Add).ToString(); - } + .SelectMany(LogEntries); + if (order == OldestToNewest) + logEntries = logEntries.Reverse(); - private static string From(IEnumerable messages) - { - return messages - .Reduce() - .SelectMany(LogEntries) + return logEntries .OrderBy(x => x.Type, Comparer) .Aggregate(new LogAggregate(), Add).ToString(); } diff --git a/test/ConventionalChangelog.Unit.Tests/A.cs b/test/ConventionalChangelog.Unit.Tests/A.cs index be1be69..6aacb09 100644 --- a/test/ConventionalChangelog.Unit.Tests/A.cs +++ b/test/ConventionalChangelog.Unit.Tests/A.cs @@ -1,6 +1,7 @@ using System.Linq; using ConventionalChangelog.Conventional; using static System.Environment; +using static ConventionalChangelog.ChangelogOrder; namespace ConventionalChangelog.Unit.Tests; @@ -8,6 +9,9 @@ internal static class A { internal class Changelog { + public static string From(params Commit[] messages) => + ConventionalChangelog.Changelog.From(messages, NewestToOldest); + private const string ChangelogTitle = "# Changelog"; private const string GeneralCodeImprovementsMessage = "*General Code Improvements*"; diff --git a/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from.cs b/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from.cs index 9f355eb..f59baaf 100644 --- a/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from.cs +++ b/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from.cs @@ -17,7 +17,7 @@ public class A_changelog_from [MemberData(nameof(NullCases))] public void null_throws_null_exception(params Commit[] nullCase) { - Action fromNull = () => Changelog.From(nullCase); + Action fromNull = () => A.Changelog.From(nullCase); fromNull.Should().Throw(); } @@ -32,7 +32,7 @@ public void null_throws_null_exception(params Commit[] nullCase) [MemberData(nameof(EmptyCases))] public void empty_changes_is_empty(params Commit[] noChanges) { - var changelog = Changelog.From(noChanges); + var changelog = A.Changelog.From(noChanges); changelog.Should().Be(A.Changelog.Empty); } @@ -41,7 +41,7 @@ public void empty_changes_is_empty(params Commit[] noChanges) [InlineData("1234: abc")] public void non_conventional_commits_is_empty(string nonConventionalCommitMessage) { - var changelog = Changelog.From(new Commit(nonConventionalCommitMessage)); + var changelog = A.Changelog.From(new Commit(nonConventionalCommitMessage)); changelog.Should().Be(A.Changelog.Empty); } @@ -58,7 +58,7 @@ public void changelog_irrelevant_conventional_commits_contains_general_code_impr var type = indicator.ToCommitType(); var conventionalCommit1 = type.CommitWith("unused description"); var conventionalCommit2 = type.CommitWith("unused description"); - var changelog = Changelog.From(conventionalCommit1, conventionalCommit2); + var changelog = A.Changelog.From(conventionalCommit1, conventionalCommit2); changelog.Should().Be(A.Changelog.WithGeneralCodeImprovementsMessage()); } } diff --git a/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits.cs b/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits.cs index 2c708e9..57f7a09 100644 --- a/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits.cs +++ b/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits.cs @@ -21,7 +21,7 @@ public void is_the_changelog_header_plus_a_group_containing_the_descriptions(Com var message1 = type.CommitWithDescription(1); var message2 = type.CommitWithDescription(2); - var changelog = Changelog.From(message1, message2); + var changelog = A.Changelog.From(message1, message2); changelog.Should().Be(A.Changelog.WithGroup(type, 1, 2)); } @@ -32,7 +32,7 @@ public void and_irrelevant_commits_contains_all_relevant_entries() var message1 = Feature.CommitWithDescription(1); var message2 = Irrelevant.CommitWithDescription(2); - var changelog = Changelog.From(message1, message2); + var changelog = A.Changelog.From(message1, message2); changelog.Should().Be(A.Changelog.WithGroup(Feature, 1)); } @@ -50,7 +50,7 @@ public void in_random_order_is_for_each_type_the_changelog_header_plus_a_group_c Bugfix.CommitWithDescription(6), }; - var changelog = Changelog.From(messages); + var changelog = A.Changelog.From(messages); changelog.Should().Be(A.Changelog .WithGroup(Feature, 1, 4) diff --git a/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_breaking_change.cs b/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_breaking_change.cs index 8de851a..b46727d 100644 --- a/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_breaking_change.cs +++ b/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_breaking_change.cs @@ -20,7 +20,7 @@ public void commit_type_contains_message_within_special_breaking_changes_group() { var breakingChange = Breaking(Feature).CommitWithDescription(1); - var changelog = Changelog.From(breakingChange); + var changelog = A.Changelog.From(breakingChange); changelog.Should().Be(A.Changelog .WithGroup(BreakingChange, 1)); @@ -32,7 +32,7 @@ public void commit_type_and_non_breaking_commit_type_contains_breaking_changes_a var breakingChange = Breaking(Feature).CommitWithDescription(1); var anotherChange = Feature.CommitWithDescription(2); - var changelog = Changelog.From(breakingChange, anotherChange); + var changelog = A.Changelog.From(breakingChange, anotherChange); changelog.Should().Be(A.Changelog .WithGroup(BreakingChange, 1) @@ -52,7 +52,7 @@ public void footer_contains_the_breaking_change_description_followed_by_the_comm var breakingChange = Feature.CommitWithDescription(1) .WithFooter(token, 2); - var changelog = Changelog.From(breakingChange); + var changelog = A.Changelog.From(breakingChange); changelog.Should().Be(A.Changelog .WithGroup(BreakingChange, 2) @@ -66,7 +66,7 @@ public void footer_and_breaking_type_contains_the_breaking_change_description_fo var breakingChange = Breaking(Feature).CommitWithDescription(1) .WithFooter(token, 2); - var changelog = Changelog.From(breakingChange); + var changelog = A.Changelog.From(breakingChange); changelog.Should().Be(A.Changelog .WithGroup(BreakingChange, 2) diff --git a/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_fixing_commits.cs b/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_fixing_commits.cs index 3b8a9f9..73ed7dc 100644 --- a/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_fixing_commits.cs +++ b/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_fixing_commits.cs @@ -23,7 +23,7 @@ public With_fixing_commits() [Fact] public void when_the_fixed_commit_is_part_of_the_changelog_excludes_the_fixing_commit_from_the_changelog() { - var changelog = Changelog.From(_fixing, _target); + var changelog = A.Changelog.From(_fixing, _target); changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 1)); } @@ -35,7 +35,7 @@ public void when_the_fixed_commit_is_part_of_the_changelog_excludes_the_fixing_c public void recognizes_fixing_commits_by_the(string footer) { var fixing = CommitTypeFor.Feature.CommitWithDescription(2).WithFooter(footer, _target.Hash); - var changelog = Changelog.From(fixing, _target); + var changelog = A.Changelog.From(fixing, _target); changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 1)); } @@ -46,7 +46,7 @@ public void { var fixing2 = CommitTypeFor.Feature.CommitWithDescription(3).WithFooter(DefaultFixToken, _fixing.Hash); - var changelog = Changelog.From(fixing2, _fixing, _target); + var changelog = A.Changelog.From(fixing2, _fixing, _target); changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 1)); } @@ -57,7 +57,7 @@ public void { var fixing2 = CommitTypeFor.Feature.CommitWithDescription(3).WithFooter(DefaultFixToken, _target.Hash); - var changelog = Changelog.From(fixing2, _fixing, _target); + var changelog = A.Changelog.From(fixing2, _fixing, _target); changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 1)); } @@ -67,7 +67,7 @@ public void when_the_fixed_commit_is_not_part_of_the_changelog_includes_fixing_c { var fixing2 = CommitTypeFor.Feature.CommitWithDescription(3).WithFooter(DefaultFixToken, "randomHash"); - var changelog = Changelog.From(fixing2, _fixing, _target); + var changelog = A.Changelog.From(fixing2, _fixing, _target); changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 3, 1)); } diff --git a/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_overriding_commits.cs b/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_overriding_commits.cs index d86ac31..3b1e12a 100644 --- a/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_overriding_commits.cs +++ b/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_overriding_commits.cs @@ -21,21 +21,21 @@ public With_overriding_commits() [Fact] public void when_the_overridden_commit_is_part_of_the_changelog_but_the_overriding_one_is_not_shows_the_overridden_commit() { - var changelog = Changelog.From(_overridden); + var changelog = A.Changelog.From(_overridden); changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 1)); } [Fact] public void when_the_overridden_and_overriding_commit_are_part_of_the_changelog_shows_the_overriding_commit() { - var changelog = Changelog.From(_overriding, _overridden); + var changelog = A.Changelog.From(_overriding, _overridden); changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 2)); } [Fact] public void when_the_overriding_commit_is_part_of_the_changelog_but_the_overridden_one_is_not_shows_the_overriding_commit() { - var changelog = Changelog.From(_overriding); + var changelog = A.Changelog.From(_overriding); changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 2)); } @@ -44,7 +44,7 @@ public void when_a_overridden_overriding_commit_is_part_of_the_changelog_shows_t { var overridingOverriding = CommitTypeFor.Feature.CommitWithDescription(3).WithFooter(DefaultOverrideToken, _overriding.Hash); - var changelog = Changelog.From(overridingOverriding, _overriding, _overridden); + var changelog = A.Changelog.From(overridingOverriding, _overriding, _overridden); changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 3)); } @@ -54,7 +54,7 @@ public void when_multiple_overriding_commits_target_a_single_commit_that_is_part { var overriding2 = CommitTypeFor.Feature.CommitWithDescription(3).WithFooter(DefaultOverrideToken, _overridden.Hash); - var changelog = Changelog.From(overriding2, _overriding, _overridden); + var changelog = A.Changelog.From(overriding2, _overriding, _overridden); changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 3, 2)); } @@ -64,7 +64,7 @@ public void when_multiple_overriding_commits_target_a_single_commit_that_is_part public void recognizes_overriding_commits_by_the(string footer) { var overridingOverriding = CommitTypeFor.Feature.CommitWithDescription(2).WithFooter(footer, _overridden.Hash); - var changelog = Changelog.From(overridingOverriding, _overridden); + var changelog = A.Changelog.From(overridingOverriding, _overridden); changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 2)); } @@ -77,7 +77,7 @@ public void recognizes_overriding_commits_by_the(string footer) public void does_not_commits_as_overriding_if_they_contain_(string footer) { var overridingOverriding = CommitTypeFor.Feature.CommitWithDescription(2).WithFooter(footer, _overridden.Hash); - var changelog = Changelog.From(overridingOverriding, _overridden); + var changelog = A.Changelog.From(overridingOverriding, _overridden); changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 2, 1)); } diff --git a/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_reverting_commits.cs b/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_reverting_commits.cs index 2936d4c..bef7838 100644 --- a/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_reverting_commits.cs +++ b/test/ConventionalChangelog.Unit.Tests/Changelog_specs/A_changelog_from_changelog_relevant_conventional_commits_with_reverting_commits.cs @@ -20,14 +20,14 @@ public With_reverting_commits() [Fact] public void when_the_reverted_commit_is_part_of_the_changelog_but_the_reverting_one_is_not_shows_the_reverted_commit() { - var changelog = Changelog.From(_reverted); + var changelog = A.Changelog.From(_reverted); changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 1)); } [Fact] public void when_the_reverted_and_reverting_commit_are_part_of_the_changelog_shows_neither() { - var changelog = Changelog.From(_reverting, _reverted); + var changelog = A.Changelog.From(_reverting, _reverted); changelog.Should().Be(A.Changelog.Empty); } @@ -35,7 +35,7 @@ public void when_the_reverted_and_reverting_commit_are_part_of_the_changelog_sho [Fact] public void when_the_reverting_commit_is_part_of_the_changelog_but_the_reverted_one_is_not_shows_the_reverting_commit() { - var changelog = Changelog.From(_reverting); + var changelog = A.Changelog.From(_reverting); changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 2)); } @@ -45,7 +45,7 @@ public void when_a_reverted_reverting_commit_is_part_of_the_changelog_shows_the_ var revertingReverting = CommitTypeFor.Feature.CommitWithDescription(3).WithFooter(DefaultRevertToken, _reverting.Hash); - var changelog = Changelog.From(revertingReverting, _reverting, _reverted); + var changelog = A.Changelog.From(revertingReverting, _reverting, _reverted); changelog.Should().Be(A.Changelog.WithGroup(CommitTypeFor.Feature, 1)); } @@ -55,7 +55,7 @@ public void when_multiple_reverting_commits_target_a_single_commit_that_is_part_ { var reverting2 = CommitTypeFor.Feature.CommitWithDescription(3).WithFooter(DefaultRevertToken, _reverted.Hash); - var changelog = Changelog.From(reverting2, _reverting, _reverted); + var changelog = A.Changelog.From(reverting2, _reverting, _reverted); changelog.Should().Be(A.Changelog.Empty); } @@ -65,7 +65,7 @@ public void when_multiple_reverting_commits_target_a_single_commit_that_is_part_ public void recognizes_reverting_commits_by_the(string footer) { var reverting = CommitTypeFor.Feature.CommitWithDescription(2).WithFooter(footer, _reverted.Hash); - var changelog = Changelog.From(reverting, _reverted); + var changelog = A.Changelog.From(reverting, _reverted); changelog.Should().Be(A.Changelog.Empty); } From 1adf14d1cffb4c9bbbd6cb7c7933457e6c3bab57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Kro=CC=88ner?= Date: Mon, 25 Sep 2023 20:19:08 +0200 Subject: [PATCH 11/13] style: Remove unnecessary blank line --- test/ConventionalChangelog.Unit.Tests/VariantsExtensions.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/test/ConventionalChangelog.Unit.Tests/VariantsExtensions.cs b/test/ConventionalChangelog.Unit.Tests/VariantsExtensions.cs index 16e704b..257c067 100644 --- a/test/ConventionalChangelog.Unit.Tests/VariantsExtensions.cs +++ b/test/ConventionalChangelog.Unit.Tests/VariantsExtensions.cs @@ -6,7 +6,6 @@ namespace ConventionalChangelog.Unit.Tests; - internal class CaseVariantDataAttribute: DataAttribute { private readonly string _source; From 29ed186259f9cbf0dd55b809333188d70d691501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Kro=CC=88ner?= Date: Tue, 26 Sep 2023 09:19:29 +0200 Subject: [PATCH 12/13] ci: Fix reference to global.json file --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 65a1176..c061a83 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -22,7 +22,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v3 with: - global-json-file: /global.json + global-json-file: global.json - name: Install dependencies run: dotnet restore From 1360756431bc1d670a17537cac6c56b0de44058e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Kro=CC=88ner?= Date: Tue, 26 Sep 2023 09:24:57 +0200 Subject: [PATCH 13/13] build: Roll forward to .NET SDK 7.0.306 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index b2e365e..57c1e51 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.300", + "version": "7.0.306", "rollForward": "latestPatch", "allowPrerelease": false }