Пример #1
0
        private static SemanticVersion EnsurePreReleaseTag(this SemanticVersion version, EffectiveConfiguration config, bool isCurrentCommitTagged)
        {
            // Continuous Deployment always requires a pre-release tag unless the commit is tagged
            if (config.VersioningMode != VersioningMode.ContinuousDeployment || isCurrentCommitTagged)
            {
                return(version);
            }

            if (!version.PreReleaseTag.IsNull())
            {
                return(version);
            }

            return(version.Copy(
                       preReleaseTag: new PreReleaseTag(
                           name: EnsurePreReleaseTagName(version, config),
                           number: version.BuildMetadata.CommitsSinceTag)));
        }
Пример #2
0
        private static SemanticVersion AppendTagNumberPattern(this SemanticVersion version, EffectiveConfiguration config)
        {
            if (!CanAppendTagNumberPattern(version, config))
            {
                return(version);
            }

            var match       = Regex.Match(version.BuildMetadata.Branch, config.TagNumberPattern);
            var numberGroup = match.Groups["number"];

            if (!numberGroup.Success)
            {
                return(version);
            }

            var tagNumberPattern = numberGroup.Value.PadLeft(config.BuildMetaDataPadding, '0');

            return(version.Copy(
                       preReleaseTag: new PreReleaseTag(
                           name: version.PreReleaseTag.Name + tagNumberPattern,
                           number: version.PreReleaseTag.Number)));
        }
Пример #3
0
        private static SemanticVersion PromoteNumberOfCommitsToTagNumber(this SemanticVersion version, EffectiveConfiguration config, bool isCurrentCommitTagged)
        {
            if (IsContinuousDeploymentMode(config, isCurrentCommitTagged) ||
                CanAppendTagNumberPattern(version, config) ||
                config.VersioningMode == VersioningMode.Mainline)
            {
                // For continuous deployment the commits since tag gets promoted to the pre-release number
                return(version.Copy(
                           preReleaseTag: new PreReleaseTag(
                               name: version.PreReleaseTag.Name,
                               number: version.BuildMetadata.CommitsSinceTag),
                           buildMetadata: new BuildMetadata(
                               commitsSinceTag: null,
                               branch: version.BuildMetadata.Branch,
                               commitHash: version.BuildMetadata.Hash,
                               commitDate: version.BuildMetadata.CommitDate,
                               commitsSinceVersionSource: version.BuildMetadata.CommitsSinceTag ?? 0,
                               otherMetadata: version.BuildMetadata.OtherMetadata)));
            }

            return(version);
        }