diff --git a/src/GitVersion.Core.Tests/Helpers/TestEffectiveConfiguration.cs b/src/GitVersion.Core.Tests/Helpers/TestEffectiveConfiguration.cs index 8e2c4ea281..1cc3306f73 100644 --- a/src/GitVersion.Core.Tests/Helpers/TestEffectiveConfiguration.cs +++ b/src/GitVersion.Core.Tests/Helpers/TestEffectiveConfiguration.cs @@ -34,13 +34,36 @@ public TestEffectiveConfiguration( bool isRelease = false, string commitDateFormat = "yyyy-MM-dd", bool updateBuildNumber = false) : - base(assemblyVersioningScheme, assemblyFileVersioningScheme, assemblyInformationalFormat, assemblyVersioningFormat, assemblyFileVersioningFormat, versioningMode, gitTagPrefix, tag, nextVersion, IncrementStrategy.Patch, - branchPrefixToTrim, preventIncrementForMergedBranchVersion, tagNumberPattern, continuousDeploymentFallbackTag, + base(assemblyVersioningScheme, + assemblyFileVersioningScheme, + assemblyInformationalFormat, + assemblyVersioningFormat, + assemblyFileVersioningFormat, + versioningMode, + gitTagPrefix, + tag, + nextVersion, + IncrementStrategy.Patch, + branchPrefixToTrim, + preventIncrementForMergedBranchVersion, + tagNumberPattern, + continuousDeploymentFallbackTag, trackMergeTarget, - majorMessage, minorMessage, patchMessage, noBumpMessage, - commitMessageMode, legacySemVerPadding, buildMetaDataPadding, commitsSinceVersionSourcePadding, + majorMessage, + minorMessage, + patchMessage, + noBumpMessage, + commitMessageMode, + legacySemVerPadding, + buildMetaDataPadding, + commitsSinceVersionSourcePadding, versionFilters ?? Enumerable.Empty(), - tracksReleaseBranches, isRelease, commitDateFormat, updateBuildNumber, 0, 0) + tracksReleaseBranches, + isRelease, + commitDateFormat, + updateBuildNumber, + 0, + 0) { } } diff --git a/src/GitVersion.Core.Tests/Model/CommitDateTests.cs b/src/GitVersion.Core.Tests/Model/CommitDateTests.cs index bd344f782b..34b89a9d4d 100644 --- a/src/GitVersion.Core.Tests/Model/CommitDateTests.cs +++ b/src/GitVersion.Core.Tests/Model/CommitDateTests.cs @@ -1,7 +1,4 @@ using GitVersion.Core.Tests.Helpers; -using GitVersion.Extensions; -using GitVersion.Model.Configuration; -using GitVersion.VersionCalculation; using NUnit.Framework; namespace GitVersion.Core.Tests; @@ -17,17 +14,20 @@ public class CommitDateTests : TestBase public void CommitDateFormatTest(string format, string expectedOutcome) { var date = new DateTime(2017, 10, 6); - - var formatValues = new SemanticVersionFormatValues( - new SemanticVersion - { - BuildMetaData = new SemanticVersionBuildMetaData("950d2f830f5a2af12a6779a48d20dcbb02351f25", 0, MainBranch, "3139d4eeb044f46057693473eacc2655b3b27e7d", "3139d4eeb", new DateTimeOffset(date, TimeSpan.Zero), 0) // assume time zone is UTC - - }, - new EffectiveConfiguration( - AssemblyVersioningScheme.MajorMinorPatch, AssemblyFileVersioningScheme.MajorMinorPatch, "", "", "", VersioningMode.ContinuousDelivery, "", "", "", IncrementStrategy.Inherit, - "", true, "", "", false, "", "", "", "", CommitMessageIncrementMode.Enabled, 4, 4, 4, Enumerable.Empty(), false, true, format, false, 0, 0) - ); + var semanticVersionBuildMetaData = new SemanticVersionBuildMetaData( + "950d2f830f5a2af12a6779a48d20dcbb02351f25", + 0, + MainBranch, + "3139d4eeb044f46057693473eacc2655b3b27e7d", + "3139d4eeb", + new DateTimeOffset(date, TimeSpan.Zero), + 0); + var semanticVersion = new SemanticVersion + { + BuildMetaData = semanticVersionBuildMetaData // assume time zone is UTC + }; + var configuration = new TestEffectiveConfiguration(commitDateFormat: format); + var formatValues = new SemanticVersionFormatValues(semanticVersion, configuration); Assert.That(formatValues.CommitDate, Is.EqualTo(expectedOutcome)); } diff --git a/src/GitVersion.Core/Configuration/ConfigExtensions.cs b/src/GitVersion.Core/Configuration/ConfigExtensions.cs index 0928da7a7e..7568c6d984 100644 --- a/src/GitVersion.Core/Configuration/ConfigExtensions.cs +++ b/src/GitVersion.Core/Configuration/ConfigExtensions.cs @@ -42,82 +42,6 @@ public static class ConfigExtensions public static bool IsReleaseBranch(this Config config, string branchName) => config.GetConfigForBranch(branchName)?.IsReleaseBranch ?? false; - public static EffectiveConfiguration CalculateEffectiveConfiguration(this Config configuration, BranchConfig currentBranchConfig) - { - var name = currentBranchConfig.Name; - if (!currentBranchConfig.VersioningMode.HasValue) - throw new Exception($"Configuration value for 'Versioning mode' for branch {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 {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 {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 {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 {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 {name} has no value. (this should not happen, please report an issue)"); - - if (!configuration.AssemblyVersioningScheme.HasValue) - throw new Exception("Configuration value for 'AssemblyVersioningScheme' has no value. (this should not happen, please report an issue)"); - if (!configuration.AssemblyFileVersioningScheme.HasValue) - throw new Exception("Configuration value for 'AssemblyFileVersioningScheme' 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)"); - if (!configuration.LegacySemVerPadding.HasValue) - throw new Exception("Configuration value for 'LegacySemVerPadding' has no value. (this should not happen, please report an issue)"); - if (!configuration.BuildMetaDataPadding.HasValue) - throw new Exception("Configuration value for 'BuildMetaDataPadding' has no value. (this should not happen, please report an issue)"); - if (!configuration.CommitsSinceVersionSourcePadding.HasValue) - throw new Exception("Configuration value for 'CommitsSinceVersionSourcePadding' has no value. (this should not happen, please report an issue)"); - if (!configuration.TagPreReleaseWeight.HasValue) - throw new Exception("Configuration value for 'TagPreReleaseWeight' 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 = configuration.NextVersion; - var assemblyVersioningScheme = configuration.AssemblyVersioningScheme.Value; - var assemblyFileVersioningScheme = configuration.AssemblyFileVersioningScheme.Value; - var assemblyInformationalFormat = configuration.AssemblyInformationalFormat; - var assemblyVersioningFormat = configuration.AssemblyVersioningFormat; - var assemblyFileVersioningFormat = configuration.AssemblyFileVersioningFormat; - var gitTagPrefix = configuration.TagPrefix; - var majorMessage = configuration.MajorVersionBumpMessage; - var minorMessage = configuration.MinorVersionBumpMessage; - var patchMessage = configuration.PatchVersionBumpMessage; - var noBumpMessage = configuration.NoBumpMessage; - var commitDateFormat = configuration.CommitDateFormat; - var updateBuildNumber = configuration.UpdateBuildNumber ?? true; - var tagPreReleaseWeight = configuration.TagPreReleaseWeight.Value; - - var commitMessageVersionBump = currentBranchConfig.CommitMessageIncrementing ?? configuration.CommitMessageIncrementing.Value; - return new EffectiveConfiguration( - assemblyVersioningScheme, assemblyFileVersioningScheme, assemblyInformationalFormat, assemblyVersioningFormat, assemblyFileVersioningFormat, versioningMode, gitTagPrefix, - tag, nextVersion, incrementStrategy, - currentBranchConfig.Regex, - preventIncrementForMergedBranchVersion, - tagNumberPattern, configuration.ContinuousDeploymentFallbackTag, - trackMergeTarget, - majorMessage, minorMessage, patchMessage, noBumpMessage, - commitMessageVersionBump, - configuration.LegacySemVerPadding.Value, - configuration.BuildMetaDataPadding.Value, - configuration.CommitsSinceVersionSourcePadding.Value, - configuration.Ignore.ToFilters(), - currentBranchConfig.TracksReleaseBranches.Value, - currentBranchConfig.IsReleaseBranch.Value, - commitDateFormat, - updateBuildNumber, - preReleaseWeight, - tagPreReleaseWeight); - } - public static string GetBranchSpecificTag(this EffectiveConfiguration configuration, ILog log, string? branchFriendlyName, string? branchNameOverride) { var tagToUse = configuration.Tag ?? "{BranchName}"; diff --git a/src/GitVersion.Core/Core/Abstractions/IRepositoryStore.cs b/src/GitVersion.Core/Core/Abstractions/IRepositoryStore.cs index 2abb051830..113472f668 100644 --- a/src/GitVersion.Core/Core/Abstractions/IRepositoryStore.cs +++ b/src/GitVersion.Core/Core/Abstractions/IRepositoryStore.cs @@ -18,6 +18,7 @@ public interface IRepositoryStore IBranch GetTargetBranch(string? targetBranchName); IBranch? FindBranch(string? branchName); + IBranch? FindMainBranch(Config configuration); IBranch? GetChosenBranch(Config configuration); IEnumerable GetBranchesForCommit(ICommit commit); IEnumerable GetExcludedInheritBranches(Config configuration); diff --git a/src/GitVersion.Core/Core/GitVersionContextFactory.cs b/src/GitVersion.Core/Core/GitVersionContextFactory.cs index 07ad156e6d..35cb1446e8 100644 --- a/src/GitVersion.Core/Core/GitVersionContextFactory.cs +++ b/src/GitVersion.Core/Core/GitVersionContextFactory.cs @@ -1,6 +1,7 @@ using GitVersion.Common; using GitVersion.Configuration; using GitVersion.Extensions; +using GitVersion.Model.Configuration; using Microsoft.Extensions.Options; namespace GitVersion; @@ -36,7 +37,7 @@ public GitVersionContext Create(GitVersionOptions gitVersionOptions) } var currentBranchConfig = this.branchConfigurationCalculator.GetBranchConfiguration(currentBranch, currentCommit, configuration); - var effectiveConfiguration = configuration.CalculateEffectiveConfiguration(currentBranchConfig); + var effectiveConfiguration = new EffectiveConfiguration(configuration, currentBranchConfig); var currentCommitTaggedVersion = this.repositoryStore.GetCurrentCommitTaggedVersion(currentCommit, effectiveConfiguration); var numberOfUncommittedChanges = this.repositoryStore.GetNumberOfUncommittedChanges(); diff --git a/src/GitVersion.Core/Core/RepositoryStore.cs b/src/GitVersion.Core/Core/RepositoryStore.cs index 7f10ffb6ab..e13385e2bf 100644 --- a/src/GitVersion.Core/Core/RepositoryStore.cs +++ b/src/GitVersion.Core/Core/RepositoryStore.cs @@ -126,6 +126,20 @@ public IBranch GetTargetBranch(string? targetBranchName) public IBranch? FindBranch(string? branchName) => this.repository.Branches.FirstOrDefault(x => x.Name.EquivalentTo(branchName)); + public IBranch? FindMainBranch(Config configuration) + { + var mainBranchRegex = configuration.Branches[Config.MainBranchKey]?.Regex + ?? configuration.Branches[Config.MasterBranchKey]?.Regex; + + if (mainBranchRegex == null) + { + return FindBranch(Config.MainBranchKey) ?? FindBranch(Config.MasterBranchKey); + } + + return this.repository.Branches.FirstOrDefault(b => + Regex.IsMatch(b.Name.Friendly, mainBranchRegex, RegexOptions.IgnoreCase)); + } + public IBranch? GetChosenBranch(Config configuration) { var developBranchRegex = configuration.Branches[Config.DevelopBranchKey]?.Regex; diff --git a/src/GitVersion.Core/Model/Configuration/EffectiveConfiguration.cs b/src/GitVersion.Core/Model/Configuration/EffectiveConfiguration.cs index 38cb2c5baf..1f94252cb2 100644 --- a/src/GitVersion.Core/Model/Configuration/EffectiveConfiguration.cs +++ b/src/GitVersion.Core/Model/Configuration/EffectiveConfiguration.cs @@ -4,18 +4,99 @@ namespace GitVersion.Model.Configuration; /// -/// Configuration can be applied to different things, effective configuration is the result after applying the appropriate configuration +/// Configuration can be applied to different things, effective configuration is the result after applying the +/// appropriate configuration /// public class EffectiveConfiguration { - public EffectiveConfiguration( - AssemblyVersioningScheme assemblyVersioningScheme, + public EffectiveConfiguration(Config configuration, BranchConfig currentBranchConfig) + { + Configuration = configuration.NotNull(); + currentBranchConfig.NotNull(); + + var name = currentBranchConfig.Name; + + if (!currentBranchConfig.VersioningMode.HasValue) + throw new Exception($"Configuration value for 'Versioning mode' for branch {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 {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 {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 {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 {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 {name} has no value. (this should not happen, please report an issue)"); + + if (!configuration.AssemblyVersioningScheme.HasValue) + throw new Exception("Configuration value for 'AssemblyVersioningScheme' has no value. (this should not happen, please report an issue)"); + + if (!configuration.AssemblyFileVersioningScheme.HasValue) + throw new Exception("Configuration value for 'AssemblyFileVersioningScheme' 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)"); + + if (!configuration.LegacySemVerPadding.HasValue) + throw new Exception("Configuration value for 'LegacySemVerPadding' has no value. (this should not happen, please report an issue)"); + + if (!configuration.BuildMetaDataPadding.HasValue) + throw new Exception("Configuration value for 'BuildMetaDataPadding' has no value. (this should not happen, please report an issue)"); + + if (!configuration.CommitsSinceVersionSourcePadding.HasValue) + throw new Exception("Configuration value for 'CommitsSinceVersionSourcePadding' has no value. (this should not happen, please report an issue)"); + + if (!configuration.TagPreReleaseWeight.HasValue) + throw new Exception("Configuration value for 'TagPreReleaseWeight' has no value. (this should not happen, please report an issue)"); + + AssemblyVersioningScheme = configuration.AssemblyVersioningScheme.Value; + AssemblyFileVersioningScheme = configuration.AssemblyFileVersioningScheme.Value; + AssemblyInformationalFormat = configuration.AssemblyInformationalFormat; + AssemblyVersioningFormat = configuration.AssemblyVersioningFormat; + AssemblyFileVersioningFormat = configuration.AssemblyFileVersioningFormat; + VersioningMode = currentBranchConfig.VersioningMode.Value; + GitTagPrefix = configuration.TagPrefix; + Tag = currentBranchConfig.Tag; + NextVersion = configuration.NextVersion; + Increment = currentBranchConfig.Increment.Value; + BranchPrefixToTrim = currentBranchConfig.Regex; + PreventIncrementForMergedBranchVersion = currentBranchConfig.PreventIncrementOfMergedBranchVersion.Value; + TagNumberPattern = currentBranchConfig.TagNumberPattern; + ContinuousDeploymentFallbackTag = configuration.ContinuousDeploymentFallbackTag; + TrackMergeTarget = currentBranchConfig.TrackMergeTarget.Value; + MajorVersionBumpMessage = configuration.MajorVersionBumpMessage; + MinorVersionBumpMessage = configuration.MinorVersionBumpMessage; + PatchVersionBumpMessage = configuration.PatchVersionBumpMessage; + NoBumpMessage = configuration.NoBumpMessage; + CommitMessageIncrementing = currentBranchConfig.CommitMessageIncrementing ?? configuration.CommitMessageIncrementing.Value; + LegacySemVerPadding = configuration.LegacySemVerPadding.Value; + BuildMetaDataPadding = configuration.BuildMetaDataPadding.Value; + CommitsSinceVersionSourcePadding = configuration.CommitsSinceVersionSourcePadding.Value; + VersionFilters = configuration.Ignore.ToFilters(); + TracksReleaseBranches = currentBranchConfig.TracksReleaseBranches.Value; + IsCurrentBranchRelease = currentBranchConfig.IsReleaseBranch.Value; + CommitDateFormat = configuration.CommitDateFormat; + UpdateBuildNumber = configuration.UpdateBuildNumber ?? true; + PreReleaseWeight = currentBranchConfig.PreReleaseWeight ?? 0; + TagPreReleaseWeight = configuration.TagPreReleaseWeight.Value; + } + + protected EffectiveConfiguration(AssemblyVersioningScheme assemblyVersioningScheme, AssemblyFileVersioningScheme assemblyFileVersioningScheme, string? assemblyInformationalFormat, string? assemblyVersioningFormat, string? assemblyFileVersioningFormat, - VersioningMode versioningMode, string? gitTagPrefix, - string? tag, string? nextVersion, IncrementStrategy increment, + VersioningMode versioningMode, + string? gitTagPrefix, + string? tag, + string? nextVersion, + IncrementStrategy increment, string? branchPrefixToTrim, bool preventIncrementForMergedBranchVersion, string? tagNumberPattern, @@ -69,62 +150,62 @@ public EffectiveConfiguration( TagPreReleaseWeight = tagPreReleaseWeight; } - public bool TracksReleaseBranches { get; private set; } - public bool IsCurrentBranchRelease { get; private set; } - - public VersioningMode VersioningMode { get; private set; } - - public AssemblyVersioningScheme AssemblyVersioningScheme { get; private set; } - public AssemblyFileVersioningScheme AssemblyFileVersioningScheme { get; private set; } - public string? AssemblyInformationalFormat { get; private set; } - public string? AssemblyVersioningFormat { get; private set; } - public string? AssemblyFileVersioningFormat { get; private set; } + public bool TracksReleaseBranches { get; } + public bool IsCurrentBranchRelease { get; } + public VersioningMode VersioningMode { get; } + public AssemblyVersioningScheme AssemblyVersioningScheme { get; } + public AssemblyFileVersioningScheme AssemblyFileVersioningScheme { get; } + public string? AssemblyInformationalFormat { get; } + public string? AssemblyVersioningFormat { get; } + public string? AssemblyFileVersioningFormat { get; } /// - /// Git tag prefix + /// Git tag prefix /// - public string? GitTagPrefix { get; private set; } + public string? GitTagPrefix { get; } /// - /// Tag to use when calculating SemVer + /// Tag to use when calculating SemVer /// - public string? Tag { get; private set; } + public string? Tag { get; } + + public string? NextVersion { get; } - public string? NextVersion { get; private set; } + public IncrementStrategy Increment { get; } - public IncrementStrategy Increment { get; private set; } + public string? BranchPrefixToTrim { get; } - public string? BranchPrefixToTrim { get; private set; } + public bool PreventIncrementForMergedBranchVersion { get; } - public bool PreventIncrementForMergedBranchVersion { get; private set; } + public string? TagNumberPattern { get; } - public string? TagNumberPattern { get; private set; } + public string? ContinuousDeploymentFallbackTag { get; } - public string? ContinuousDeploymentFallbackTag { get; private set; } + public bool TrackMergeTarget { get; } - public bool TrackMergeTarget { get; private set; } + public string? MajorVersionBumpMessage { get; } - public string? MajorVersionBumpMessage { get; private set; } + public string? MinorVersionBumpMessage { get; } - public string? MinorVersionBumpMessage { get; private set; } + public string? PatchVersionBumpMessage { get; } - public string? PatchVersionBumpMessage { get; private set; } + public string? NoBumpMessage { get; } + public int LegacySemVerPadding { get; } + public int BuildMetaDataPadding { get; } - public string? NoBumpMessage { get; private set; } - public int LegacySemVerPadding { get; private set; } - public int BuildMetaDataPadding { get; private set; } + public int CommitsSinceVersionSourcePadding { get; } - public int CommitsSinceVersionSourcePadding { get; private set; } + public CommitMessageIncrementMode CommitMessageIncrementing { get; } - public CommitMessageIncrementMode CommitMessageIncrementing { get; private set; } + public IEnumerable VersionFilters { get; } - public IEnumerable VersionFilters { get; private set; } + public string? CommitDateFormat { get; } - public string? CommitDateFormat { get; private set; } + public bool UpdateBuildNumber { get; } - public bool UpdateBuildNumber { get; private set; } + public int PreReleaseWeight { get; } - public int PreReleaseWeight { get; private set; } + public int TagPreReleaseWeight { get; } - public int TagPreReleaseWeight { get; private set; } + public Config Configuration { get; } } diff --git a/src/GitVersion.Core/VersionCalculation/BaseVersionCalculators/TrackReleaseBranchesVersionStrategy.cs b/src/GitVersion.Core/VersionCalculation/BaseVersionCalculators/TrackReleaseBranchesVersionStrategy.cs index f8d123eba7..6cbdfd4ad0 100644 --- a/src/GitVersion.Core/VersionCalculation/BaseVersionCalculators/TrackReleaseBranchesVersionStrategy.cs +++ b/src/GitVersion.Core/VersionCalculation/BaseVersionCalculators/TrackReleaseBranchesVersionStrategy.cs @@ -1,7 +1,6 @@ using GitVersion.Common; using GitVersion.Configuration; using GitVersion.Extensions; -using GitVersion.Model.Configuration; namespace GitVersion.VersionCalculation; @@ -26,14 +25,16 @@ public class TrackReleaseBranchesVersionStrategy : VersionStrategyBase private readonly IRepositoryStore repositoryStore; private readonly VersionInBranchNameVersionStrategy releaseVersionStrategy; private readonly TaggedCommitVersionStrategy taggedCommitVersionStrategy; + private readonly Lazy context; + public TrackReleaseBranchesVersionStrategy(IRepositoryStore repositoryStore, Lazy versionContext) : base(versionContext) { this.repositoryStore = repositoryStore.NotNull(); - this.releaseVersionStrategy = new VersionInBranchNameVersionStrategy(repositoryStore, versionContext); this.taggedCommitVersionStrategy = new TaggedCommitVersionStrategy(repositoryStore, versionContext); + this.context = versionContext.NotNull(); } public override IEnumerable GetVersions() => @@ -43,8 +44,12 @@ public override IEnumerable GetVersions() => private IEnumerable MainTagsVersions() { - var main = this.repositoryStore.FindBranch(Config.MainBranchKey); - return main != null ? this.taggedCommitVersionStrategy.GetTaggedVersions(main, null) : Array.Empty(); + var configuration = this.context.Value.Configuration.Configuration; + var main = this.repositoryStore.FindMainBranch(configuration); + + return main != null + ? this.taggedCommitVersionStrategy.GetTaggedVersions(main, null) + : Array.Empty(); } private IEnumerable ReleaseBranchBaseVersions()