GetBranchConfiguration() public static méthode

Gets the BranchConfig for the current commit.
public static GetBranchConfiguration ( GitVersionContext context, Branch targetBranch, IList excludedInheritBranches = null ) : GitVersion.BranchConfig
context GitVersionContext
targetBranch Branch
excludedInheritBranches IList
Résultat GitVersion.BranchConfig
Exemple #1
0
        void CalculateEffectiveConfiguration()
        {
            var currentBranchConfig = BranchConfigurationCalculator.GetBranchConfiguration(CurrentCommit, Repository, OnlyEvaluateTrackedBranches, configuration, CurrentBranch);

            if (!currentBranchConfig.Value.VersioningMode.HasValue)
            {
                throw new Exception(string.Format("Configuration value for 'Versioning mode' for branch {0} has no value. (this should not happen, please report an issue)", currentBranchConfig.Key));
            }
            if (!currentBranchConfig.Value.Increment.HasValue)
            {
                throw new Exception(string.Format("Configuration value for 'Increment' for branch {0} has no value. (this should not happen, please report an issue)", currentBranchConfig.Key));
            }
            if (!currentBranchConfig.Value.PreventIncrementOfMergedBranchVersion.HasValue)
            {
                throw new Exception(string.Format("Configuration value for 'PreventIncrementOfMergedBranchVersion' for branch {0} has no value. (this should not happen, please report an issue)", currentBranchConfig.Key));
            }
            if (!currentBranchConfig.Value.TrackMergeTarget.HasValue)
            {
                throw new Exception(string.Format("Configuration value for 'TrackMergeTarget' for branch {0} has no value. (this should not happen, please report an issue)", currentBranchConfig.Key));
            }
            if (!configuration.AssemblyVersioningScheme.HasValue)
            {
                throw new Exception("Configuration value for 'AssemblyVersioningScheme' has no value. (this should not happen, please report an issue)");
            }
            if (!configuration.CommitMessageIncrementing.HasValue)
            {
                throw new Exception("Configuration value for 'CommitMessageIncrementing' has no value. (this should not happen, please report an issue)");
            }

            var versioningMode    = currentBranchConfig.Value.VersioningMode.Value;
            var tag               = currentBranchConfig.Value.Tag;
            var tagNumberPattern  = currentBranchConfig.Value.TagNumberPattern;
            var incrementStrategy = currentBranchConfig.Value.Increment.Value;
            var preventIncrementForMergedBranchVersion = currentBranchConfig.Value.PreventIncrementOfMergedBranchVersion.Value;
            var trackMergeTarget = currentBranchConfig.Value.TrackMergeTarget.Value;

            var nextVersion = configuration.NextVersion;
            var assemblyVersioningScheme    = configuration.AssemblyVersioningScheme.Value;
            var assemblyInformationalFormat = configuration.AssemblyInformationalFormat;
            var gitTagPrefix = configuration.TagPrefix;
            var majorMessage = configuration.MajorVersionBumpMessage;
            var minorMessage = configuration.MinorVersionBumpMessage;
            var patchMessage = configuration.PatchVersionBumpMessage;

            var commitMessageVersionBump = currentBranchConfig.Value.CommitMessageIncrementing ?? configuration.CommitMessageIncrementing.Value;

            Configuration = new EffectiveConfiguration(
                assemblyVersioningScheme, assemblyInformationalFormat, versioningMode, gitTagPrefix,
                tag, nextVersion, incrementStrategy, currentBranchConfig.Key,
                preventIncrementForMergedBranchVersion,
                tagNumberPattern, configuration.ContinuousDeploymentFallbackTag,
                trackMergeTarget,
                majorMessage, minorMessage, patchMessage,
                commitMessageVersionBump,
                configuration.LegacySemVerPadding.Value,
                configuration.BuildMetaDataPadding.Value,
                configuration.CommitsSinceVersionSourcePadding.Value);
        }
Exemple #2
0
        void CalculateEffectiveConfiguration()
        {
            var currentBranchConfig = BranchConfigurationCalculator.GetBranchConfiguration(CurrentCommit, Repository, OnlyEvaluateTrackedBranches, configuration, CurrentBranch);

            if (!currentBranchConfig.Value.VersioningMode.HasValue)
            {
                throw new Exception(string.Format("Configuration value for 'Versioning mode' for branch {0} has no value. (this should not happen, please report an issue)", currentBranchConfig.Key));
            }
            if (!currentBranchConfig.Value.Increment.HasValue)
            {
                throw new Exception(string.Format("Configuration value for 'Increment' for branch {0} has no value. (this should not happen, please report an issue)", currentBranchConfig.Key));
            }
            if (!currentBranchConfig.Value.PreventIncrementOfMergedBranchVersion.HasValue)
            {
                throw new Exception(string.Format("Configuration value for 'PreventIncrementOfMergedBranchVersion' for branch {0} has no value. (this should not happen, please report an issue)", currentBranchConfig.Key));
            }
            if (!currentBranchConfig.Value.TrackMergeTarget.HasValue)
            {
                throw new Exception(string.Format("Configuration value for 'TrackMergeTarget' for branch {0} has no value. (this should not happen, please report an issue)", currentBranchConfig.Key));
            }
            if (!configuration.AssemblyVersioningScheme.HasValue)
            {
                throw new Exception("Configuration value for 'AssemblyVersioningScheme' has no value. (this should not happen, please report an issue)");
            }

            var versioningMode    = currentBranchConfig.Value.VersioningMode.Value;
            var tag               = currentBranchConfig.Value.Tag;
            var tagNumberPattern  = currentBranchConfig.Value.TagNumberPattern;
            var incrementStrategy = currentBranchConfig.Value.Increment.Value;
            var preventIncrementForMergedBranchVersion = currentBranchConfig.Value.PreventIncrementOfMergedBranchVersion.Value;
            var trackMergeTarget = currentBranchConfig.Value.TrackMergeTarget.Value;

            var nextVersion = configuration.NextVersion;
            var assemblyVersioningScheme = configuration.AssemblyVersioningScheme.Value;
            var gitTagPrefix             = configuration.TagPrefix;

            Configuration = new EffectiveConfiguration(
                assemblyVersioningScheme, versioningMode, gitTagPrefix,
                tag, nextVersion, incrementStrategy, currentBranchConfig.Key,
                preventIncrementForMergedBranchVersion,
                tagNumberPattern, configuration.ContinuousDeploymentFallbackTag,
                trackMergeTarget);
        }
Exemple #3
0
        void CalculateEffectiveConfiguration()
        {
            var currentBranchConfig = BranchConfigurationCalculator.GetBranchConfiguration(CurrentCommit, Repository, OnlyEvaluateTrackedBranches, configuration, CurrentBranch);

            var versioningMode    = currentBranchConfig.Value.VersioningMode ?? configuration.VersioningMode ?? VersioningMode.ContinuousDelivery;
            var tag               = currentBranchConfig.Value.Tag ?? "useBranchName";
            var nextVersion       = configuration.NextVersion;
            var incrementStrategy = currentBranchConfig.Value.Increment ?? IncrementStrategy.Patch;
            var preventIncrementForMergedBranchVersion = currentBranchConfig.Value.PreventIncrementOfMergedBranchVersion ?? false;
            var assemblyVersioningScheme = configuration.AssemblyVersioningScheme;
            var gitTagPrefix             = configuration.TagPrefix;
            var tagNumberPattern         = currentBranchConfig.Value.TagNumberPattern;

            Configuration = new EffectiveConfiguration(
                assemblyVersioningScheme, versioningMode, gitTagPrefix,
                tag, nextVersion, incrementStrategy, currentBranchConfig.Key,
                preventIncrementForMergedBranchVersion,
                tagNumberPattern, configuration.ContinuousDeploymentFallbackTag,
                currentBranchConfig.Value.TrackMergeTarget);
        }
Exemple #4
0
        private void CalculateEffectiveConfiguration()
        {
            IBranchConfigurationCalculator calculator = new BranchConfigurationCalculator(log, this);
            var currentBranchConfig = calculator.GetBranchConfiguration(CurrentBranch);

            if (!currentBranchConfig.VersioningMode.HasValue)
            {
                throw new Exception($"Configuration value for 'Versioning mode' for branch {currentBranchConfig.Name} has no value. (this should not happen, please report an issue)");
            }
            if (!currentBranchConfig.Increment.HasValue)
            {
                throw new Exception($"Configuration value for 'Increment' for branch {currentBranchConfig.Name} has no value. (this should not happen, please report an issue)");
            }
            if (!currentBranchConfig.PreventIncrementOfMergedBranchVersion.HasValue)
            {
                throw new Exception($"Configuration value for 'PreventIncrementOfMergedBranchVersion' for branch {currentBranchConfig.Name} has no value. (this should not happen, please report an issue)");
            }
            if (!currentBranchConfig.TrackMergeTarget.HasValue)
            {
                throw new Exception($"Configuration value for 'TrackMergeTarget' for branch {currentBranchConfig.Name} has no value. (this should not happen, please report an issue)");
            }
            if (!currentBranchConfig.TracksReleaseBranches.HasValue)
            {
                throw new Exception($"Configuration value for 'TracksReleaseBranches' for branch {currentBranchConfig.Name} has no value. (this should not happen, please report an issue)");
            }
            if (!currentBranchConfig.IsReleaseBranch.HasValue)
            {
                throw new Exception($"Configuration value for 'IsReleaseBranch' for branch {currentBranchConfig.Name} has no value. (this should not happen, please report an issue)");
            }

            if (!FullConfiguration.AssemblyVersioningScheme.HasValue)
            {
                throw new Exception("Configuration value for 'AssemblyVersioningScheme' has no value. (this should not happen, please report an issue)");
            }
            if (!FullConfiguration.AssemblyFileVersioningScheme.HasValue)
            {
                throw new Exception("Configuration value for 'AssemblyFileVersioningScheme' has no value. (this should not happen, please report an issue)");
            }
            if (!FullConfiguration.CommitMessageIncrementing.HasValue)
            {
                throw new Exception("Configuration value for 'CommitMessageIncrementing' has no value. (this should not happen, please report an issue)");
            }
            if (!FullConfiguration.LegacySemVerPadding.HasValue)
            {
                throw new Exception("Configuration value for 'LegacySemVerPadding' has no value. (this should not happen, please report an issue)");
            }
            if (!FullConfiguration.BuildMetaDataPadding.HasValue)
            {
                throw new Exception("Configuration value for 'BuildMetaDataPadding' has no value. (this should not happen, please report an issue)");
            }
            if (!FullConfiguration.CommitsSinceVersionSourcePadding.HasValue)
            {
                throw new Exception("Configuration value for 'CommitsSinceVersionSourcePadding' has no value. (this should not happen, please report an issue)");
            }

            var versioningMode    = currentBranchConfig.VersioningMode.Value;
            var tag               = currentBranchConfig.Tag;
            var tagNumberPattern  = currentBranchConfig.TagNumberPattern;
            var incrementStrategy = currentBranchConfig.Increment.Value;
            var preventIncrementForMergedBranchVersion = currentBranchConfig.PreventIncrementOfMergedBranchVersion.Value;
            var trackMergeTarget = currentBranchConfig.TrackMergeTarget.Value;
            var preReleaseWeight = currentBranchConfig.PreReleaseWeight ?? 0;

            var nextVersion = FullConfiguration.NextVersion;
            var assemblyVersioningScheme     = FullConfiguration.AssemblyVersioningScheme.Value;
            var assemblyFileVersioningScheme = FullConfiguration.AssemblyFileVersioningScheme.Value;
            var assemblyInformationalFormat  = FullConfiguration.AssemblyInformationalFormat;
            var assemblyVersioningFormat     = FullConfiguration.AssemblyVersioningFormat;
            var assemblyFileVersioningFormat = FullConfiguration.AssemblyFileVersioningFormat;
            var gitTagPrefix     = FullConfiguration.TagPrefix;
            var majorMessage     = FullConfiguration.MajorVersionBumpMessage;
            var minorMessage     = FullConfiguration.MinorVersionBumpMessage;
            var patchMessage     = FullConfiguration.PatchVersionBumpMessage;
            var noBumpMessage    = FullConfiguration.NoBumpMessage;
            var commitDateFormat = FullConfiguration.CommitDateFormat;

            var commitMessageVersionBump = currentBranchConfig.CommitMessageIncrementing ?? FullConfiguration.CommitMessageIncrementing.Value;

            Configuration = new EffectiveConfiguration(
                assemblyVersioningScheme, assemblyFileVersioningScheme, assemblyInformationalFormat, assemblyVersioningFormat, assemblyFileVersioningFormat, versioningMode, gitTagPrefix,
                tag, nextVersion, incrementStrategy,
                currentBranchConfig.Regex,
                preventIncrementForMergedBranchVersion,
                tagNumberPattern, FullConfiguration.ContinuousDeploymentFallbackTag,
                trackMergeTarget,
                majorMessage, minorMessage, patchMessage, noBumpMessage,
                commitMessageVersionBump,
                FullConfiguration.LegacySemVerPadding.Value,
                FullConfiguration.BuildMetaDataPadding.Value,
                FullConfiguration.CommitsSinceVersionSourcePadding.Value,
                FullConfiguration.Ignore.ToFilters(),
                currentBranchConfig.TracksReleaseBranches.Value,
                currentBranchConfig.IsReleaseBranch.Value,
                commitDateFormat,
                preReleaseWeight);
        }