Пример #1
0
        public static VersionVariables GetVariablesFor(SemanticVersion semanticVersion, EffectiveConfiguration config, bool isCurrentCommitTagged)
        {
            if (config.VersioningMode == VersioningMode.ContinuousDeployment && !isCurrentCommitTagged)
            {
                semanticVersion = new SemanticVersion(semanticVersion);
                // Continuous Deployment always requires a pre-release tag unless the commit is tagged
                if (!semanticVersion.PreReleaseTag.HasTag())
                {
                    semanticVersion.PreReleaseTag.Name = config.ContinuousDeploymentFallbackTag;
                }

                // For continuous deployment the commits since tag gets promoted to the pre-release number
                semanticVersion.PreReleaseTag.Number = semanticVersion.BuildMetaData.CommitsSinceTag;
                semanticVersion.BuildMetaData.CommitsSinceVersionSource = semanticVersion.BuildMetaData.CommitsSinceTag ?? 0;
                semanticVersion.BuildMetaData.CommitsSinceTag           = null;
            }

            var semverFormatValues = new SemanticVersionFormatValues(semanticVersion, config);

            string informationalVersion;

            if (string.IsNullOrEmpty(config.AssemblyInformationalFormat))
            {
                informationalVersion = semverFormatValues.DefaultInformationalVersion;
            }
            else
            {
                try
                {
                    informationalVersion = config.AssemblyInformationalFormat.FormatWith(semverFormatValues);
                }
                catch (FormatException formex)
                {
                    throw new WarningException(string.Format("Unable to format AssemblyInformationalVersion.  Check your format string: {0}", formex.Message));
                }
            }

            var variables = new VersionVariables(
                semverFormatValues.Major,
                semverFormatValues.Minor,
                semverFormatValues.Patch,
                semverFormatValues.BuildMetaData,
                semverFormatValues.BuildMetaDataPadded,
                semverFormatValues.FullBuildMetaData,
                semverFormatValues.BranchName,
                semverFormatValues.Sha,
                semverFormatValues.MajorMinorPatch,
                semverFormatValues.SemVer,
                semverFormatValues.LegacySemVer,
                semverFormatValues.LegacySemVerPadded,
                semverFormatValues.FullSemVer,
                semverFormatValues.AssemblySemVer,
                semverFormatValues.PreReleaseTag,
                semverFormatValues.PreReleaseTagWithDash,
                informationalVersion,
                semverFormatValues.CommitDate,
                semverFormatValues.NuGetVersion,
                semverFormatValues.NuGetVersionV2,
                semverFormatValues.CommitsSinceVersionSource,
                semverFormatValues.CommitsSinceVersionSourcePadded);

            return(variables);
        }
 public SemanticVersionFormatValues(SemanticVersion semver, EffectiveConfiguration config)
 {
     _semver = semver;
     _config = config;
 }
Пример #3
0
        public GitVersionContext(IBranch currentBranch, ICommit currentCommit,
                                 Config configuration, EffectiveConfiguration effectiveConfiguration, SemanticVersion currentCommitTaggedVersion, int numberOfUncommittedChanges)
        {
            CurrentCommit = currentCommit;
            CurrentBranch = currentBranch;

            FullConfiguration = configuration;
            Configuration     = effectiveConfiguration;

            CurrentCommitTaggedVersion = currentCommitTaggedVersion;

            NumberOfUncommittedChanges = numberOfUncommittedChanges;
        }