예제 #1
0
        public void GetDeletedReminders_return_removed_files_with_complex_history()
        {
            var commitModel = new[]
            {
                new CallbackModel.CommitModel
                {
                    Removed = new[]
                    {
                        ".reminders/jsonInReminders.json",
                    }
                },
                new CallbackModel.CommitModel
                {
                    Added = new[]
                    {
                        ".reminders/jsonInReminders.json",
                    }
                },
                new CallbackModel.CommitModel
                {
                    Removed = new[]
                    {
                        ".reminders/jsonInReminders.json",
                    }
                }
            };

            var result = CommitParser.GetDeletedReminders(commitModel);

            var file = Assert.Single(result);

            Assert.Equal(".reminders/jsonInReminders.json", file);
        }
예제 #2
0
        public void GetReminders_Should_return_added_reverted_added_again_file()
        {
            var commitModel = new[]
            {
                new CallbackModel.CommitModel
                {
                    Added = new[]
                    {
                        ".reminders/jsonInReminders.json",
                    }
                },
                new CallbackModel.CommitModel
                {
                    Removed = new[]
                    {
                        ".reminders/jsonInReminders.json",
                    }
                },
                new CallbackModel.CommitModel
                {
                    Added = new[]
                    {
                        ".reminders/jsonInReminders.json",
                    }
                },
            };

            var result = CommitParser.GetReminders(commitModel);

            var file = Assert.Single(result);

            Assert.Equal(".reminders/jsonInReminders.json", file);
        }
예제 #3
0
        public void GetDeletedReminders_should_return_removed_modified_files()
        {
            var commitModel = new[]
            {
                new CallbackModel.CommitModel
                {
                    Modified = new[]
                    {
                        ".reminders/jsonInReminders.json",
                    }
                },
                new CallbackModel.CommitModel
                {
                    Removed = new[]
                    {
                        ".reminders/jsonInReminders.json",
                    }
                }
            };

            var result = CommitParser.GetDeletedReminders(commitModel);

            var file = Assert.Single(result);

            Assert.Equal(".reminders/jsonInReminders.json", file);
        }
예제 #4
0
 public void SetUp()
 {
     _settings = new Settings
     {
         CardIdRegex = Settings.DEFAULT_CARD_ID_REGEX,
     };
     _parser = new CommitParser(_settings);
 }
예제 #5
0
        void TestCommitHasNoBug(string hash, Option <SearchOptions> options)
        {
            var commit = CommitFinder.ParseSingle(TestDataLocator.GetPath(), hash);

            Assert.True(commit.HasValue);
            commit.MatchSome(c => {
                var parsedCommits = CommitParser.ParseSingle(c, options.ValueOr(new SearchOptions()));
                Assert.Zero(parsedCommits.Count());
            });
        }
        public void ParsingEmptyGitHistory()
        {
            var commits = Array.Empty <CommitInfoWrapper>();

            var parser = new CommitParser(this.defaultConfig, this.repository, this.writer);

            var result = parser.ParseVersionFromCommits(commits);

            Approvals.Verify(result);
            result.Version.Commits.ShouldBe(0);
        }
예제 #7
0
        /// <summary>
        ///     Get the next applicable version of the project.
        /// </summary>
        /// <param name="repository">Repository of the project.</param>
        /// <returns>A <see cref="ProjectVersion"/> representing the next version.</returns>
        public ProjectVersion GetNextVersion(Repository repository)
        {
            var versionTag = repository.GetVersionTag(Version);
            var commits    = repository.GetCommitsSinceLastVersion(versionTag);

            var isMaster = repository.Head.FriendlyName == "master";

            Commits = CommitParser.Parse(commits);
            var incrementStrategy = VersionIncrementStrategy.Create(Commits, isMaster);

            return(incrementStrategy.NextVersion(Version));
        }
예제 #8
0
        public void CommitParser_SmokeTestAllCommits()
        {
            var commits       = CommitFinder.Parse(TestDataLocator.GetPath(), new SearchRange());
            var parsedCommits = CommitParser.Parse(commits, new SearchOptions());

            Assert.NotZero(commits.Count());
            foreach (var parsedCommit in parsedCommits)
            {
                Assert.IsNotNull(parsedCommit.Commit.Title);
                Assert.IsNotNull(parsedCommit.Link);
            }
        }
예제 #9
0
        void TestMultipleCommits(string hash, List <string> expectedUrls, Option <SearchOptions> options)
        {
            var commit = CommitFinder.ParseSingle(TestDataLocator.GetPath(), hash);

            Assert.IsTrue(commit.HasValue);
            commit.MatchSome(c =>
            {
                var parsedCommits = CommitParser.ParseSingle(c, options.ValueOr(new SearchOptions())).ToList();
                Assert.AreEqual(parsedCommits.Count(), expectedUrls.Count);
                Assert.True(new HashSet <string> (parsedCommits.Select(x => x.Link)).SetEquals(expectedUrls));
            });
        }
예제 #10
0
        public void ParseSingleFeatureTagCommit()
        {
            var commits = new[]
            {
                new CommitInfoWrapper(true, "1.1.0", "feat: some kind of new feature")
            };

            var parser = new CommitParser(this.defaultConfig, this.repository, this.writer);

            var result = parser.ParseVersionFromCommits(commits);

            Approvals.Verify(result);
        }
예제 #11
0
        public void ParseSingleFixTagCommit()
        {
            var commits = new[]
            {
                new CommitInfoWrapper(true, "1.0.1", "fix: some kind of bugfix"),
            };

            var parser = new CommitParser(this.defaultConfig, this.repository, this.writer);

            var result = parser.ParseVersionFromCommits(commits);

            Approvals.Verify(result);
        }
예제 #12
0
        public void ParseNonChangelogCommit()
        {
            var commits = new[]
            {
                new CommitInfoWrapper(true, "1.0.1", "chore: some update"),
            };

            var parser = new CommitParser(this.defaultConfig, this.repository, this.writer);

            var result = parser.ParseVersionFromCommits(commits);

            Approvals.Verify(result);
        }
예제 #13
0
        public void ParseId_CustomRegex(string regex, string comment, string expected)
        {
            // Assemble
            var parser = new CommitParser(new Settings {
                CardIdRegex = regex
            });

            // Act
            string actual = parser.ParseId(comment);

            // Assert
            Assert.AreEqual(expected, actual);
        }
        public void ParsingTagWithoutPreviousCommits()
        {
            var commits = new[]
            {
                new CommitInfoWrapper(true, "1.5.2", "feat: some feature")
            };

            var parser = new CommitParser(this.defaultConfig, this.repository, this.writer);

            var result = parser.ParseVersionFromCommits(commits);

            Approvals.Verify(result);
            result.Version.Commits.ShouldBe(1);
        }
        public void ParsingTaggedNonAlphaCommit()
        {
            var commits = new[]
            {
                new CommitInfoWrapper(true, "1.3.3-beta.5", "fix: yup this happened")
            };

            var parser = new CommitParser(this.defaultConfig, this.repository, this.writer);

            var result = parser.ParseVersionFromCommits(commits);

            Approvals.Verify(result);
            result.Version.Commits.ShouldBe(1);
        }
        public void ParsingUnstableTaggedFeatureCommit()
        {
            var commits = new[]
            {
                new CommitInfoWrapper(true, "1.3.0-alpha.1", "feat: some awesome feature")
            };

            var parser = new CommitParser(this.defaultConfig, this.repository, this.writer);

            var result = parser.ParseVersionFromCommits(commits);

            Approvals.Verify(result);
            result.Version.Commits.ShouldBe(1);
        }
        public void ParsingSingleFixCommit()
        {
            var commits = new[]
            {
                new CommitInfoWrapper("fix: correct unintentional bug"),
            };

            var parser = new CommitParser(this.defaultConfig, this.repository, this.writer);

            var result = parser.ParseVersionFromCommits(commits);

            Approvals.Verify(result);
            result.Version.Commits.ShouldBe(1);
        }
        public void ParsingSingleFeatureCommit()
        {
            var commits = new[]
            {
                new CommitInfoWrapper("feat: some kind of awesome feature"),
            };

            var parser = new CommitParser(this.defaultConfig, this.repository, this.writer);

            var result = parser.ParseVersionFromCommits(commits);

            Approvals.Verify(result);
            result.Version.Commits.ShouldBe(1);
        }
        public void ParsingTaggedCommitWithoutVersion()
        {
            var commits = new[]
            {
                new CommitInfoWrapper(true, "invalid", "feat: test commit")
            };

            var parser = new CommitParser(this.defaultConfig, this.repository, this.writer);

            var result = parser.ParseVersionFromCommits(commits);

            Approvals.Verify(result);
            result.Version.Commits.ShouldBe(1);
        }
        public void ParsingSingleFixCommitWithPreviousTag()
        {
            var commits = new[]
            {
                new CommitInfoWrapper("fix: correct code"),
                new CommitInfoWrapper(true, "3.1.1", "docs: update changelog")
            };

            var parser = new CommitParser(this.defaultConfig, this.repository, this.writer);

            var result = parser.ParseVersionFromCommits(commits);

            Approvals.Verify(result);
            result.Version.Commits.ShouldBe(1);
        }
        public void ParsingSingleFeatureWithPreviousTag()
        {
            var commits = new[]
            {
                new CommitInfoWrapper("feat: some kind of awesome feature"),
                new CommitInfoWrapper(true, "1.2.3", "docs: update changelog")
            };

            var parser = new CommitParser(this.defaultConfig, this.repository, this.writer);

            var result = parser.ParseVersionFromCommits(commits);

            Approvals.Verify(result);
            result.Version.Commits.ShouldBe(1);
        }
        public void ParsingMergeCommitAfterTag()
        {
            var commits = new[]
            {
                new CommitInfoWrapper("Merge master into develop"),
                new CommitInfoWrapper(true, "1.3.5", "feat: awesome")
            };

            var parser = new CommitParser(this.defaultConfig, this.repository, this.writer);

            var result = parser.ParseVersionFromCommits(commits);

            Approvals.Verify(result);
            result.Version.Commits.ShouldBe(1);
        }
        public void ParsingSingleFixCommitWithPreviousTagSuggfixTag(string tagSuffix)
        {
            var commits = new[]
            {
                new CommitInfoWrapper("fix: something"),
                new CommitInfoWrapper(true, $"v1.3.1-{tagSuffix}.2", "docs: update changelog")
            };

            var parser = new CommitParser(this.defaultConfig, this.repository, this.writer);

            var result = parser.ParseVersionFromCommits(commits);

            Approvals.Verify(result.ToString(), s => s.Replace("-" + tagSuffix, "-tag-suffix"));
            result.Version.Commits.ShouldBe(1);
        }
예제 #24
0
        public void ParsingMultipeCommitTypes()
        {
            var commits = new[]
            {
                new CommitInfoWrapper("feat: some kind of new feature"),
                new CommitInfoWrapper("fix(scoping): some kind of bug fix"),
                new CommitInfoWrapper("refactor!: renamed a method in the public API")
            };

            var parser = new CommitParser(this.defaultConfig, this.repository, this.writer);

            var result = parser.ParseVersionFromCommits(commits);

            Approvals.Verify(result);
        }
        public void ParsingBreakingFeatureCommit()
        {
            var commits = new[]
            {
                new CommitInfoWrapper("feat!: this is a major breaking change"),
                new CommitInfoWrapper(true, "v1.2.0", "docs: update changelog")
            };

            var parser = new CommitParser(this.defaultConfig, this.repository, this.writer);

            var result = parser.ParseVersionFromCommits(commits);

            Approvals.Verify(result);
            result.Version.Commits.ShouldBe(1);
        }
        public void ParsingCommitWithBreakingBody()
        {
            var commits = new[]
            {
                new CommitInfoWrapper("feat: some new feature\n\nSome body\n\nBREAKING CHANGE: Important breaking change"),
                new CommitInfoWrapper(true, "1.0.0", "docs: update changelog")
            };

            var parser = new CommitParser(this.defaultConfig, this.repository, this.writer);

            var result = parser.ParseVersionFromCommits(commits);

            Approvals.Verify(result);
            result.Version.Commits.ShouldBe(1);
        }
        public void ParsingMultipleUnstableFeatureCommitsWithTag()
        {
            var commits = new[]
            {
                new CommitInfoWrapper(true, "1.4.4-alpha.1", "feat: awesome: tag commit"),
                new CommitInfoWrapper("feat: this is just a commit")
            };

            var parser = new CommitParser(this.defaultConfig, this.repository, this.writer);

            var result = parser.ParseVersionFromCommits(commits);

            Approvals.Verify(result);
            result.Version.Commits.ShouldBe(2);
        }
        public void ParsingTagWithLowerVersionThanPreviousTag()
        {
            var commits = new[]
            {
                new CommitInfoWrapper(true, "2.1.0", "fix: major breaking change"),
                new CommitInfoWrapper(true, "3.0.0", "feat!: previous breaking")
            };

            var parser = new CommitParser(this.defaultConfig, this.repository, this.writer);

            var result = parser.ParseVersionFromCommits(commits);

            Approvals.Verify(result);
            result.Version.Commits.ShouldBe(1);
        }
예제 #29
0
        public void ParsingCommitsWithIssueReferences(string closeType)
        {
            var commits = new[]
            {
                new CommitInfoWrapper(true, "1.0.0", "docs: update changelog"),
                new CommitInfoWrapper($"feat: some feature\n\n{closeType} #54\n{closeType} #43"),
                new CommitInfoWrapper($"chore: some chore\n\n{closeType} #22")
            };

            var parser = new CommitParser(this.defaultConfig, this.repository, this.writer);

            var result = parser.ParseVersionFromCommits(commits);

            Approvals.Verify(result);
        }
예제 #30
0
        public void ParsingMergeCommits()
        {
            var commits = new[]
            {
                new CommitInfoWrapper(true, "1.0.0", "docs: update changelog"),
                new CommitInfoWrapper("Merge develop into master"),
                new CommitInfoWrapper("feat: some feature"),
                new CommitInfoWrapper("(build) not considered")
            };

            var parser = new CommitParser(this.defaultConfig, this.repository, this.writer);

            var result = parser.ParseVersionFromCommits(commits);

            Approvals.Verify(result);
        }