private static VersionNumber GenerateDevelopVersionNumber( IGitRepoReader repo, DevelopBranchInfo develop, string headCommitHash) => new VersionNumber( repo.CurrentCoreVersion.Major, repo.CurrentCoreVersion.Minor + 1, 0, develop.DeterminePreReleaseLabel(repo.CommitCountDevelopSinceLastMinorCoreVersion), headCommitHash);
private static VersionNumber GenerateFeatureVersionNumber( IGitRepoReader repo, FeatureBranchInfo feature, string headCommitHash) { var preReleaseLabel = feature.DeterminePreReleaseLabel( repo.CommitCountDevelopSinceLastMinorCoreVersion, repo.CommitCountUniqueToFeature); return new VersionNumber( repo.CurrentCoreVersion.Major, repo.CurrentCoreVersion.Minor + 1, 0, preReleaseLabel, headCommitHash); }
private static VersionNumber GenerateReleaseCanditateVersionNumber( IGitRepoReader repo, ReleaseCandidateBranchInfo releaseCandidate, string headCommitHash) { var ordinal = repo.HighestMatchingTagForReleaseCandidate?.PreReleaseLabel?.BranchLabel .Ordinal + 1; var preReleaseLabel = releaseCandidate.DeterminePreReleaseLabel(ordinal ?? 1); var version = releaseCandidate.VersionFromName; return new VersionNumber( version.Major, version.Minor, version.Patch, preReleaseLabel, headCommitHash); }
internal static VersionNumber GenerateVersionNumber(IGitRepoReader repo) { var currentBranch = repo.CurrentBranch; var headCommitHash = repo.HeadCommitHash.Length > Constants.BuildMetadataHashLength ? repo.HeadCommitHash.Substring(0, Constants.BuildMetadataHashLength) : repo.HeadCommitHash; var tagOnHead = repo.TagOnHead; return(currentBranch switch { FeatureBranchInfo feature => GenerateFeatureVersionNumber(repo, feature, headCommitHash), ReleaseCandidateBranchInfo releaseCandidate => GenerateReleaseCandidateVersionNumber(repo, releaseCandidate, headCommitHash), DevelopBranchInfo develop => GenerateDevelopVersionNumber(repo, develop, headCommitHash), MasterBranchInfo _ when TagOnHeadIsMajorMinorPatch(tagOnHead) => VersionNumber.Parse(tagOnHead.FriendlyName), _ => throw new ArgumentOutOfRangeException( $"'{currentBranch.Name}' is not a branch that is supported for automated version generation, please tag the commit manualy.", nameof(currentBranch.Name)) });