public SemanticVersion NextVersion() { var versionZero = new SemanticVersion(); var lastRelease = lastTaggedReleaseFinder.GetVersion().SemVer; var fileVersion = nextVersionTxtFileFinder.GetNextVersion(); var mergedBranchVersion = mergedBranchesWithVersionFinder.GetVersion(); var otherBranchVersion = unknownBranchFinder.FindVersion(context); if (otherBranchVersion != null && otherBranchVersion.PreReleaseTag != null && otherBranchVersion.PreReleaseTag.Name == "release") { otherBranchVersion.PreReleaseTag.Name = "beta"; } var maxCalculated = new[] { fileVersion, otherBranchVersion, mergedBranchVersion }.Max(); if (lastRelease == versionZero && maxCalculated == versionZero) { return(new SemanticVersion { Minor = 1 }); } if (maxCalculated <= lastRelease) { return(new SemanticVersion { Major = lastRelease.Major, Minor = lastRelease.Minor, Patch = lastRelease.Patch + 1 }); } return(maxCalculated); }
public IEnumerable <SemanticVersion> GetPossibleVersions() { VersionTaggedCommit lastTaggedRelease; if (lastTaggedReleaseFinder.GetVersion(out lastTaggedRelease)) { //If the exact commit is tagged then just return that commit if (context.CurrentCommit.Sha == lastTaggedRelease.Commit.Sha) { yield return(lastTaggedRelease.SemVer); yield break; } yield return(new SemanticVersion { Major = lastTaggedRelease.SemVer.Major, Minor = lastTaggedRelease.SemVer.Minor, Patch = lastTaggedRelease.SemVer.Patch + 1 }); } SemanticVersion fileVersion; if (nextVersionTxtFileFinder.TryGetNextVersion(out fileVersion)) { yield return(fileVersion); } SemanticVersion tryGetVersion; if (mergedBranchesWithVersionFinder.TryGetVersion(out tryGetVersion)) { yield return(tryGetVersion); } SemanticVersion otherBranchVersion; if (unknownBranchFinder.FindVersion(context, out otherBranchVersion)) { yield return(otherBranchVersion); } }
public IEnumerable <SemanticVersion> GetPossibleVersions() { // always provide a minimum fallback version for other strategies var defaultNextVersion = new SemanticVersion { Minor = 1 }; yield return(defaultNextVersion); VersionTaggedCommit lastTaggedRelease; if (lastTaggedReleaseFinder.GetVersion(out lastTaggedRelease)) { //If the exact commit is tagged then just return that commit if (context.CurrentCommit.Sha == lastTaggedRelease.Commit.Sha) { yield return(lastTaggedRelease.SemVer); yield break; } defaultNextVersion = new SemanticVersion { Major = lastTaggedRelease.SemVer.Major, Minor = lastTaggedRelease.SemVer.Minor, Patch = lastTaggedRelease.SemVer.Patch + 1 }; yield return(defaultNextVersion); } SemanticVersion fileVersion; var hasNextVersionTxtVersion = nextVersionTxtFileFinder.TryGetNextVersion(out fileVersion); if (hasNextVersionTxtVersion && !string.IsNullOrEmpty(context.Configuration.NextVersion)) { throw new Exception("You cannot specify a next version in both NextVersion.txt and GitVersionConfig.yaml. Please delete NextVersion.txt and use GitVersionConfig.yaml"); } if (!string.IsNullOrEmpty(context.Configuration.NextVersion)) { yield return(SemanticVersion.Parse(context.Configuration.NextVersion, context.Configuration.TagPrefix)); } if (hasNextVersionTxtVersion) { yield return(fileVersion); } SemanticVersion tryGetVersion; if (mergedBranchesWithVersionFinder.TryGetVersion(out tryGetVersion)) { yield return(tryGetVersion); } SemanticVersion otherBranchVersion; if (unknownBranchFinder.FindVersion(context, defaultNextVersion, out otherBranchVersion)) { yield return(otherBranchVersion); } }