コード例 #1
0
 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);
 }
コード例 #2
0
        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))
            });