Beispiel #1
0
        public void FeatureDebugMergedVersion()
        {
            var repoReader = new GitRepoReader(TestRepositories.FeatureDebugMergedRepository(), string.Empty);

            repoReader.CommitCountDevelopSinceLastMinorCoreVersion.Should().Be(4);
            repoReader.CommitCountUniqueToFeature.Should().Be(7);
        }
 /// <summary>
 /// Generate a VersionNumber for the git repository.
 /// </summary>
 /// <param name="path">The path to the git repository.</param>
 /// <param name="branch">The name of the branch to consider when generating the version number.</param>
 /// <returns></returns>
 public static VersionNumber GenerateVersionNumber(
     string path,
     string branch)
 {
     var repo = GitRepoReader.Load(path, branch);
     return GenerateVersionNumber(repo);
 }
Beispiel #3
0
        public void MasterPastDevelopTest()
        {
            var repoReader = new GitRepoReader(TestRepositories.MasterAheadOfDevelopRepository(), string.Empty);

            repoReader.CurrentBranch.Name.Should().Be(DashDashVersion.Constants.DevelopBranchName);
            repoReader.CommitCountDevelopSinceLastMinorCoreVersion.Should().Be(1);
            repoReader.HeadCommitHash.Should().Be("b");
            repoReader.CurrentCoreVersion.SemVer.Should().Be("0.0.0");
        }
Beispiel #4
0
        public void FeatureRepoTest()
        {
            var repoReader = new GitRepoReader(TestRepositories.FeatureBranchOnFeatureBranchRepository(), string.Empty);

            repoReader.CommitCountUniqueToFeature.Should().Be(2);
            repoReader.CommitCountDevelopSinceLastMinorCoreVersion.Should().Be(1);
            repoReader.HeadCommitHash.Should().Be("d");
            repoReader.CurrentCoreVersion.SemVer.Should().Be("0.0.0");
            repoReader.CurrentBranch.Name.Should().Be($"{DashDashVersion.Constants.FeatureBranchName}/B");
        }
Beispiel #5
0
        public void RemoteDevelopRepoTest()
        {
            var repoReader = new GitRepoReader(TestRepositories.RemoteDevelopRepository(), string.Empty);

            repoReader.CommitCountUniqueToFeature.Should().Be(0);
            repoReader.CommitCountDevelopSinceLastMinorCoreVersion.Should().Be(1);
            repoReader.CurrentBranch.Name.Should().Be(DashDashVersion.Constants.DevelopBranchName);
            repoReader.CurrentCoreVersion.SemVer.Should().Be("0.0.0");
            repoReader.HeadCommitHash.Should().Be("b");
        }
Beispiel #6
0
        public void ReleaseRepoWithTagTest()
        {
            var repoReader = new GitRepoReader(TestRepositories.ReleaseBranchRepositoryWithTaggedRc(), string.Empty);

            repoReader.CommitCountUniqueToFeature.Should().Be(3);
            repoReader.CommitCountDevelopSinceLastMinorCoreVersion.Should().Be(1);
            repoReader.HeadCommitHash.Should().Be("e");
            repoReader.CurrentCoreVersion.SemVer.Should().Be("0.0.0");
            repoReader.CurrentBranch.Name.Should().Be($"{DashDashVersion.Constants.ReleaseBranchName}/1.0.0");
            repoReader.HighestMatchingTagForReleaseCandidate?.ToString().Should().Be("1.0.0-rc.2");
        }
        /// <summary>
        /// Generate a VersionNumber for the git repository.
        /// </summary>
        /// <param name="path">The path to the git repository.</param>
        /// <param name="branch">The name of the branch to consider when generating the version number.</param>
        /// <param name="checkIfRepoIsClean">Whether or not the repository needs to be in a clean state.</param>
        /// <returns></returns>
        public static VersionNumber GenerateVersionNumber(
            string path,
            string branch,
            bool checkIfRepoIsClean)
        {
            var repo = GitRepoReader.Load(path, branch);

            if (checkIfRepoIsClean && repo.RepoIsDirty)
            {
                throw new  InvalidDataException("The repository is not in a clean state, please commit all changes or disable this check.");
            }
            return(GenerateVersionNumber(repo));
        }