예제 #1
0
    public void ShouldHideFixSectionWhenHideIsTrue()
    {
        var plainLinkBuilder = new PlainLinkBuilder();
        var changelog        = ChangelogBuilder.CreateForPath(_testDirectory);

        changelog.Write(
            new Version(1, 1, 0),
            new DateTimeOffset(),
            plainLinkBuilder,
            new List <ConventionalCommit>
        {
            ConventionalCommitParser.Parse(new TestCommit("a360d6a307909c6e571b29d4a329fd786c5d4543", "fix: a fix")),
            ConventionalCommitParser.Parse(new TestCommit("b360d6a307909c6e571b29d4a329fd786c5d4543", "feat: a feature")),
        },
            ChangelogOptions.Default with
        {
            Sections = new[]
            {
                new ChangelogSection {
                    Type = "feat", Hidden = false, Section = "Features"
                },
                new ChangelogSection {
                    Type = "fix", Hidden = true, Section = "Bug Fixes"
                },
            }
        });
예제 #2
0
        public void ShouldAppendToExistingChangelog()
        {
            var parser = new ConventionalCommitParser();

            var plainLinkBuilder = new PlainLinkBuilder();
            var changelog        = Changelog.Discover(_testDirectory);

            changelog.Write(new Version(1, 0, 0), new DateTimeOffset(), plainLinkBuilder, new List <ConventionalCommit>
            {
                parser.Parse(new TestCommit("a360d6a307909c6e571b29d4a329fd786c5d4543", "fix: a fix in version 1.0.0")),
            });

            changelog.Write(new Version(1, 1, 0), new DateTimeOffset(), plainLinkBuilder, new List <ConventionalCommit>
            {
                parser.Parse(new TestCommit("b360d6a307909c6e571b29d4a329fd786c5d4543", "fix: a fix in version 1.1.0")),
            });

            var changelogContents = File.ReadAllText(changelog.FilePath);

            changelogContents.ShouldContain("<a name=\"1.0.0\"></a>");
            changelogContents.ShouldContain("a fix in version 1.0.0");

            changelogContents.ShouldContain("<a name=\"1.1.0\"></a>");
            changelogContents.ShouldContain("a fix in version 1.1.0");
        }
예제 #3
0
    public void ShouldGenerateAChangelogForFixFeatAndBreakingCommits()
    {
        var plainLinkBuilder = new PlainLinkBuilder();
        var changelog        = ChangelogBuilder.CreateForPath(_testDirectory);

        changelog.Write(
            new Version(1, 1, 0),
            new DateTimeOffset(),
            plainLinkBuilder,
            new List <ConventionalCommit>
        {
            ConventionalCommitParser.Parse(new TestCommit("a360d6a307909c6e571b29d4a329fd786c5d4543", "fix: a fix")),
            ConventionalCommitParser.Parse(new TestCommit("b360d6a307909c6e571b29d4a329fd786c5d4543", "feat: a feature")),
            ConventionalCommitParser.Parse(
                new TestCommit("c360d6a307909c6e571b29d4a329fd786c5d4543", "feat: a breaking change feature\nBREAKING CHANGE: this will break everything")),
        },
            ChangelogOptions.Default);

        var changelogContents = File.ReadAllText(changelog.FilePath);

        var sb = new ChangelogStringBuilder();

        sb.Append(ChangelogOptions.Preamble);
        sb.Append("<a name=\"1.1.0\"></a>");
        sb.Append("## 1.1.0 (1-1-1)", 2);
        sb.Append("### Features", 2);
        sb.Append("* a breaking change feature");
        sb.Append("* a feature", 2);
        sb.Append("### Bug Fixes", 2);
        sb.Append("* a fix", 2);
        sb.Append("### Breaking Changes", 2);
        sb.Append("* a breaking change feature", 2);
        Assert.Equal(sb.Build(), changelogContents);
    }
예제 #4
0
        public void ShouldGenerateAChangelogEvenForEmptyCommits()
        {
            var plainLinkBuilder = new PlainLinkBuilder();
            var changelog        = Changelog.Discover(_testDirectory);

            changelog.Write(new Version(1, 1, 0), new DateTimeOffset(), plainLinkBuilder, new List <ConventionalCommit>());

            var wasChangelogWritten = File.Exists(Path.Join(_testDirectory, "CHANGELOG.md"));

            Assert.True(wasChangelogWritten);
        }
예제 #5
0
        public void ShouldAppendAtEndIfChangelogContainsExtraInformation()
        {
            File.WriteAllText(Path.Combine(_testDirectory, "CHANGELOG.md"), "# Should be kept by versionize\n\nSome information about the changelog");

            var plainLinkBuilder = new PlainLinkBuilder();
            var changelog        = Changelog.Discover(_testDirectory);

            changelog.Write(new Version(1, 0, 0), new DateTimeOffset(), plainLinkBuilder, new List <ConventionalCommit>
            {
                ConventionalCommitParser.Parse(new TestCommit("a360d6a307909c6e571b29d4a329fd786c5d4543", "fix: a fix in version 1.0.0")),
            });

            var changelogContents = File.ReadAllText(changelog.FilePath);

            changelogContents.ShouldBe("# Should be kept by versionize\n\nSome information about the changelog\n\n<a name=\"1.0.0\"></a>\n## 1.0.0 (1-1-1)\n\n### Bug Fixes\n\n* a fix in version 1.0.0\n\n");
        }
예제 #6
0
        public void ShouldIncludeAllCommitsInChangelogWhenGiven()
        {
            var plainLinkBuilder = new PlainLinkBuilder();
            var changelog        = Changelog.Discover(_testDirectory);

            changelog.Write(new Version(1, 1, 0), new DateTimeOffset(), plainLinkBuilder, new List <ConventionalCommit>
            {
                ConventionalCommitParser.Parse(new TestCommit("a360d6a307909c6e571b29d4a329fd786c5d4543", "chore: nothing important")),
                ConventionalCommitParser.Parse(new TestCommit("b360d6a307909c6e571b29d4a329fd786c5d4543", "chore: some foo bar")),
            }, true);

            var changelogContents = File.ReadAllText(changelog.FilePath);

            changelogContents.ShouldContain("nothing important");
            changelogContents.ShouldContain("some foo bar");
        }
예제 #7
0
    public void ShouldGenerateWithoutLiteralLineBreakCharacters()
    {
        var plainLinkBuilder = new PlainLinkBuilder();
        var changelog        = ChangelogBuilder.CreateForPath(_testDirectory);

        changelog.Write(
            new Version(1, 1, 0),
            new DateTimeOffset(),
            plainLinkBuilder,
            new List <ConventionalCommit>
        {
            ConventionalCommitParser.Parse(new TestCommit("a360d6a307909c6e571b29d4a329fd786c5d4543", "fix: a fix")),
        },
            ChangelogOptions.Default);

        var contents = File.ReadAllText(Path.Join(_testDirectory, "CHANGELOG.md"));

        contents.ShouldNotContain("\\n");
    }
예제 #8
0
        public void ShouldGenerateAChangelogForFixFeatAndBreakingCommits()
        {
            var plainLinkBuilder = new PlainLinkBuilder();
            var changelog        = Changelog.Discover(_testDirectory);

            changelog.Write(new Version(1, 1, 0), new DateTimeOffset(), plainLinkBuilder, new List <ConventionalCommit>
            {
                ConventionalCommitParser.Parse(new TestCommit("a360d6a307909c6e571b29d4a329fd786c5d4543", "fix: a fix")),
                ConventionalCommitParser.Parse(new TestCommit("b360d6a307909c6e571b29d4a329fd786c5d4543", "feat: a feature")),
                ConventionalCommitParser.Parse(
                    new TestCommit("c360d6a307909c6e571b29d4a329fd786c5d4543", "feat: a breaking change feature\nBREAKING CHANGE: this will break everything")),
            });

            var wasChangelogWritten = File.Exists(Path.Join(_testDirectory, "CHANGELOG.md"));

            Assert.True(wasChangelogWritten);

            // TODO: Assert changelog entries
        }