public void ReturnsSameSemanticVersionAsNextVersionCalculator()
        {
            _lastTaggedReleaseFinder.GetVersion().Returns(new VersionTaggedCommit(null, null));
            var semver = new SemanticVersion(0, 1, 2);

            _nextSemver.NextVersion().Returns(semver);

            var buildNumber = _sut.GetBuildNumber();

            Assert.Equal(semver, buildNumber);
        }
Ejemplo n.º 2
0
        public SemanticVersion GetBuildNumber()
        {
            var             commitsSinceLastRelease = _gitHelper.NumberOfCommitsOnBranchSinceCommit(_gitRepo.Head, _lastTaggedReleaseFinder.GetVersion().Commit);
            SemanticVersion semanticVersion         = _nextSemverCalculator.NextVersion();

            if (_buildServer.IsBuildingAPullRequest(_gitRepo))
            {
                _gitHelper.EnsurePullBranchShareACommonAncestorWithMaster(_gitRepo, _gitRepo.Head);
                semanticVersion = semanticVersion.WithSuffix("PullRequest" + _buildServer.CurrentPullRequestNo(_gitRepo.Head));
            }
            var withBuildMetaData = semanticVersion.WithBuildMetaData(commitsSinceLastRelease);

            Console.WriteLine("Version number is '{0}'", withBuildMetaData);
            return(withBuildMetaData);
        }