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);
        }
        public void SameVersionShouldBumpPatchVersion()
        {
            var currentVersion = new SemanticVersion(0, 1, 0);
            var commit         = Substitute.For <Commit>();

            _lastTaggedReleaseFinder.GetVersion().Returns(new VersionTaggedCommit(commit, currentVersion));
            _txtFileVersion.GetNextVersion(currentVersion).Returns(currentVersion);

            var nextVersion = _sut.NextVersion();

            Assert.Equal(new SemanticVersion(0, 1, 1), nextVersion);
        }
Ejemplo n.º 3
0
        public SemanticVersion NextVersion()
        {
            SemanticVersion lastRelease = _lastTaggedReleaseFinder.GetVersion().SemVer;
            SemanticVersion fileVersion = _nextVersionTxtFileFinder.GetNextVersion(lastRelease);

            if (fileVersion <= lastRelease)
            {
                return(new SemanticVersion(lastRelease.Major, lastRelease.Minor, lastRelease.Patch + 1));
            }

            return(fileVersion);
        }
Ejemplo n.º 4
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);
        }