From 458090a69b53e7c909269f0c811f544e3dbfadb0 Mon Sep 17 00:00:00 2001 From: Artur Stolear Date: Wed, 29 Mar 2023 13:56:45 +0200 Subject: [PATCH] use IBranchConfiguration instead of BranchConfiguration --- .../ConfigurationExtensionsTests.cs | 2 +- .../BranchConfigurationBuilder.cs | 4 +-- .../Configuration/ConfigurationBuilderBase.cs | 8 +++--- .../IgnoreConfigurationBuilder.cs | 2 +- src/GitVersion.Core/PublicAPI.Unshipped.txt | 27 ------------------- 5 files changed, 8 insertions(+), 35 deletions(-) diff --git a/src/GitVersion.Core.Tests/Configuration/ConfigurationExtensionsTests.cs b/src/GitVersion.Core.Tests/Configuration/ConfigurationExtensionsTests.cs index 1aa8147b48..817753962f 100644 --- a/src/GitVersion.Core.Tests/Configuration/ConfigurationExtensionsTests.cs +++ b/src/GitVersion.Core.Tests/Configuration/ConfigurationExtensionsTests.cs @@ -9,7 +9,7 @@ public class ConfigurationExtensionsTests : TestBase [Test] public void GetReleaseBranchConfigReturnsAllReleaseBranches() { - var configuration = new GitVersionConfiguration() + var configuration = new GitVersionConfiguration { Branches = new Dictionary { diff --git a/src/GitVersion.Core/Configuration/BranchConfigurationBuilder.cs b/src/GitVersion.Core/Configuration/BranchConfigurationBuilder.cs index 28b9aeb90e..2f7db23cb3 100644 --- a/src/GitVersion.Core/Configuration/BranchConfigurationBuilder.cs +++ b/src/GitVersion.Core/Configuration/BranchConfigurationBuilder.cs @@ -2,7 +2,7 @@ namespace GitVersion.Configuration; -public class BranchConfigurationBuilder +internal class BranchConfigurationBuilder { public static BranchConfigurationBuilder New => new(); @@ -148,7 +148,7 @@ public virtual BranchConfigurationBuilder WithConfiguration(IBranchConfiguration return this; } - public BranchConfiguration Build() => new() + public IBranchConfiguration Build() => new BranchConfiguration { VersioningMode = versioningMode, Label = label, diff --git a/src/GitVersion.Core/Configuration/ConfigurationBuilderBase.cs b/src/GitVersion.Core/Configuration/ConfigurationBuilderBase.cs index 6b3965b1fe..85d31138f7 100644 --- a/src/GitVersion.Core/Configuration/ConfigurationBuilderBase.cs +++ b/src/GitVersion.Core/Configuration/ConfigurationBuilderBase.cs @@ -169,7 +169,7 @@ public virtual TConfigurationBuilder WithLabelPreReleaseWeight(int? value) public virtual TConfigurationBuilder WithIgnoreConfiguration(IIgnoreConfiguration value) { - this.ignore = (IgnoreConfiguration) value; + this.ignore = (IgnoreConfiguration)value; return (TConfigurationBuilder)this; } @@ -346,7 +346,7 @@ public virtual IGitVersionConfiguration Build() Dictionary branches = new(); foreach (var (name, branchConfigurationBuilder) in this.branchConfigurationBuilders) { - branches.Add(name, branchConfigurationBuilder.Build()); + branches.Add(name, (BranchConfiguration)branchConfigurationBuilder.Build()); } IGitVersionConfiguration configuration = new GitVersionConfiguration @@ -411,10 +411,10 @@ private static void FinalizeConfiguration(IGitVersionConfiguration configuration private static void FinalizeBranchConfiguration(IGitVersionConfiguration configuration, string branchName, IBranchConfiguration branchConfiguration) { - var branches = configuration.Branches.ToDictionary(x => x.Key, x => (BranchConfiguration)x.Value); + var branches = configuration.Branches; foreach (var targetBranchName in branchConfiguration.IsSourceBranchFor) { - var targetBranchConfiguration = branches[targetBranchName]; + var targetBranchConfiguration = (BranchConfiguration)branches[targetBranchName]; targetBranchConfiguration.SourceBranches.Add(branchName); } } diff --git a/src/GitVersion.Core/Configuration/IgnoreConfigurationBuilder.cs b/src/GitVersion.Core/Configuration/IgnoreConfigurationBuilder.cs index 0b367d320f..6825ad091f 100644 --- a/src/GitVersion.Core/Configuration/IgnoreConfigurationBuilder.cs +++ b/src/GitVersion.Core/Configuration/IgnoreConfigurationBuilder.cs @@ -32,7 +32,7 @@ public IgnoreConfigurationBuilder WithShas(HashSet value) return this; } - public IgnoreConfiguration Build() => new() + public IIgnoreConfiguration Build() => new IgnoreConfiguration() { Before = before, Shas = shas diff --git a/src/GitVersion.Core/PublicAPI.Unshipped.txt b/src/GitVersion.Core/PublicAPI.Unshipped.txt index d73a5d24f4..80308a2f31 100644 --- a/src/GitVersion.Core/PublicAPI.Unshipped.txt +++ b/src/GitVersion.Core/PublicAPI.Unshipped.txt @@ -109,8 +109,6 @@ GitVersion.Configuration.BranchConfiguration.TrackMergeMessage.get -> bool? GitVersion.Configuration.BranchConfiguration.TrackMergeTarget.get -> bool? GitVersion.Configuration.BranchConfiguration.TracksReleaseBranches.get -> bool? GitVersion.Configuration.BranchConfiguration.VersioningMode.get -> GitVersion.VersionCalculation.VersioningMode? -GitVersion.Configuration.BranchConfigurationBuilder -GitVersion.Configuration.BranchConfigurationBuilder.Build() -> GitVersion.Configuration.BranchConfiguration! GitVersion.Configuration.ConfigurationConstants GitVersion.Configuration.ConfigurationException GitVersion.Configuration.ConfigurationException.ConfigurationException() -> void @@ -225,8 +223,6 @@ GitVersion.Configuration.IgnoreConfiguration.Before.init -> void GitVersion.Configuration.IgnoreConfiguration.Shas.get -> System.Collections.Generic.HashSet! GitVersion.Configuration.IgnoreConfiguration.Shas.init -> void GitVersion.Configuration.IgnoreConfigurationExtensions -GitVersion.Configuration.Init.EditConfigStep -GitVersion.Configuration.Init.EditConfigStep.EditConfigStep(GitVersion.Logging.IConsole! console, GitVersion.IFileSystem! fileSystem, GitVersion.Logging.ILog! log, GitVersion.Configuration.Init.Wizard.IConfigInitStepFactory! stepFactory) -> void GitVersion.Configuration.Init.GitVersionInitModule GitVersion.Configuration.Init.GitVersionInitModule.GitVersionInitModule() -> void GitVersion.Configuration.Init.GitVersionInitModule.RegisterTypes(Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> void @@ -939,10 +935,6 @@ GitVersion.WixInfo.WixInfo() -> void abstract GitVersion.Agents.BuildAgentBase.EnvironmentVariable.get -> string! abstract GitVersion.Agents.BuildAgentBase.GenerateSetParameterMessage(string! name, string? value) -> string![]! abstract GitVersion.Agents.BuildAgentBase.GenerateSetVersionMessage(GitVersion.OutputVariables.GitVersionVariables! variables) -> string? -abstract GitVersion.Configuration.Init.Wizard.ConfigInitWizardStep.DefaultResult.get -> string? -abstract GitVersion.Configuration.Init.Wizard.ConfigInitWizardStep.GetPrompt(GitVersion.Configuration.GitVersionConfiguration! configuration, string! workingDirectory) -> string! -abstract GitVersion.Configuration.Init.Wizard.ConfigInitWizardStep.HandleResult(string? result, System.Collections.Generic.Queue! steps, GitVersion.Configuration.GitVersionConfiguration! configuration, string! workingDirectory) -> GitVersion.Configuration.Init.StepResult! -abstract GitVersion.GitVersionModule.RegisterTypes(Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> void abstract GitVersion.VersionCalculation.VersionStrategyBase.GetBaseVersions(GitVersion.Configuration.EffectiveBranchConfiguration! configuration) -> System.Collections.Generic.IEnumerable! const GitVersion.Configuration.ConfigurationConstants.BranchNamePlaceholder = "{BranchName}" -> string! const GitVersion.Configuration.ConfigurationConstants.DefaultLabelPrefix = "[vV]?" -> string! @@ -1011,7 +1003,6 @@ override GitVersion.VersionCalculation.VersionInBranchNameVersionStrategy.GetBas readonly GitVersion.Agents.BuildAgentBase.Log -> GitVersion.Logging.ILog! static GitVersion.BranchCommit.operator !=(GitVersion.BranchCommit left, GitVersion.BranchCommit right) -> bool static GitVersion.BranchCommit.operator ==(GitVersion.BranchCommit left, GitVersion.BranchCommit right) -> bool -static GitVersion.Configuration.BranchConfigurationBuilder.New.get -> GitVersion.Configuration.BranchConfigurationBuilder! static GitVersion.Configuration.ConfigurationExtensions.FindGitDir(this string! path) -> (string! GitDirectory, string! WorkingTreeDirectory)? static GitVersion.Configuration.ConfigurationExtensions.GetBranchConfiguration(this GitVersion.Configuration.IGitVersionConfiguration! configuration, GitVersion.IBranch! branch) -> GitVersion.Configuration.IBranchConfiguration! static GitVersion.Configuration.ConfigurationExtensions.GetBranchConfiguration(this GitVersion.Configuration.IGitVersionConfiguration! configuration, GitVersion.ReferenceName! branchName) -> GitVersion.Configuration.IBranchConfiguration! @@ -1144,23 +1135,5 @@ virtual GitVersion.Agents.BuildAgentBase.PreventFetch() -> bool virtual GitVersion.Agents.BuildAgentBase.ShouldCleanUpRemotes() -> bool virtual GitVersion.Agents.BuildAgentBase.WriteIntegration(System.Action! writer, GitVersion.OutputVariables.GitVersionVariables! variables, bool updateBuildNumber = true) -> void virtual GitVersion.Configuration.BranchConfiguration.Inherit(GitVersion.Configuration.IBranchConfiguration! configuration) -> GitVersion.Configuration.IBranchConfiguration! -virtual GitVersion.Configuration.BranchConfigurationBuilder.WithCommitMessageIncrementing(GitVersion.VersionCalculation.CommitMessageIncrementMode? value) -> GitVersion.Configuration.BranchConfigurationBuilder! -virtual GitVersion.Configuration.BranchConfigurationBuilder.WithConfiguration(GitVersion.Configuration.IBranchConfiguration! value) -> GitVersion.Configuration.BranchConfigurationBuilder! -virtual GitVersion.Configuration.BranchConfigurationBuilder.WithIncrement(GitVersion.IncrementStrategy value) -> GitVersion.Configuration.BranchConfigurationBuilder! -virtual GitVersion.Configuration.BranchConfigurationBuilder.WithIsMainline(bool? value) -> GitVersion.Configuration.BranchConfigurationBuilder! -virtual GitVersion.Configuration.BranchConfigurationBuilder.WithIsReleaseBranch(bool? value) -> GitVersion.Configuration.BranchConfigurationBuilder! -virtual GitVersion.Configuration.BranchConfigurationBuilder.WithIsSourceBranchFor(System.Collections.Generic.IEnumerable! values) -> GitVersion.Configuration.BranchConfigurationBuilder! -virtual GitVersion.Configuration.BranchConfigurationBuilder.WithIsSourceBranchFor(params string![]! values) -> GitVersion.Configuration.BranchConfigurationBuilder! -virtual GitVersion.Configuration.BranchConfigurationBuilder.WithLabel(string? value) -> GitVersion.Configuration.BranchConfigurationBuilder! -virtual GitVersion.Configuration.BranchConfigurationBuilder.WithLabelNumberPattern(string? value) -> GitVersion.Configuration.BranchConfigurationBuilder! -virtual GitVersion.Configuration.BranchConfigurationBuilder.WithPreReleaseWeight(int? value) -> GitVersion.Configuration.BranchConfigurationBuilder! -virtual GitVersion.Configuration.BranchConfigurationBuilder.WithPreventIncrementOfMergedBranchVersion(bool? value) -> GitVersion.Configuration.BranchConfigurationBuilder! -virtual GitVersion.Configuration.BranchConfigurationBuilder.WithRegularExpression(string? value) -> GitVersion.Configuration.BranchConfigurationBuilder! -virtual GitVersion.Configuration.BranchConfigurationBuilder.WithSourceBranches(System.Collections.Generic.IEnumerable! values) -> GitVersion.Configuration.BranchConfigurationBuilder! -virtual GitVersion.Configuration.BranchConfigurationBuilder.WithSourceBranches(params string![]! values) -> GitVersion.Configuration.BranchConfigurationBuilder! -virtual GitVersion.Configuration.BranchConfigurationBuilder.WithTrackMergeMessage(bool? value) -> GitVersion.Configuration.BranchConfigurationBuilder! -virtual GitVersion.Configuration.BranchConfigurationBuilder.WithTrackMergeTarget(bool? value) -> GitVersion.Configuration.BranchConfigurationBuilder! -virtual GitVersion.Configuration.BranchConfigurationBuilder.WithTracksReleaseBranches(bool? value) -> GitVersion.Configuration.BranchConfigurationBuilder! -virtual GitVersion.Configuration.BranchConfigurationBuilder.WithVersioningMode(GitVersion.VersionCalculation.VersioningMode? value) -> GitVersion.Configuration.BranchConfigurationBuilder! virtual GitVersion.VersionCalculation.EffectiveBranchConfigurationFinder.GetConfigurations(GitVersion.IBranch! branch, GitVersion.Configuration.IGitVersionConfiguration! configuration) -> System.Collections.Generic.IEnumerable! virtual GitVersion.VersionCalculation.NextVersionCalculator.FindVersion() -> GitVersion.VersionCalculation.NextVersion!