Skip to content

Commit 8c8b08e

Browse files
committed
Change *VersionCalculator implement a single common interface IVersionModeCalculator
1 parent 7970077 commit 8c8b08e

16 files changed

+43
-73
lines changed

src/GitVersion.Core.Tests/VersionCalculation/NextVersionCalculatorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@
496496
// null
497497
// );
498498
// var mainlineVersionCalculatorMock = Substitute.For<IMainlineVersionCalculator>();
499-
// mainlineVersionCalculatorMock.FindMainlineModeVersion(Arg.Any<NextVersion>()).Returns(lowerVersion.SemanticVersion);
499+
// mainlineVersionCalculatorMock.Calculate(Arg.Any<NextVersion>()).Returns(lowerVersion.SemanticVersion);
500500
// var continuousDeploymentVersionCalculatorMock = Substitute.For<IContinuousDeploymentVersionCalculator>();
501501

502502
// var versionStrategies = new IVersionStrategy[] { new TestVersionStrategy(preReleaseVersion, lowerVersion) };

src/GitVersion.Core.Tests/VersionCalculation/TestMainlineVersionCalculator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
namespace GitVersion.Core.Tests.VersionCalculation;
44

5-
public class TestMainlineVersionCalculator : IMainlineVersionCalculator
5+
public class TestMainlineVersionCalculator : IVersionModeCalculator
66
{
77
private readonly SemanticVersionBuildMetaData metaData;
88

99
public TestMainlineVersionCalculator(SemanticVersionBuildMetaData metaData) => this.metaData = metaData;
1010

11-
public SemanticVersion FindMainlineModeVersion(NextVersion nextVersion) => throw new NotImplementedException();
11+
public SemanticVersion Calculate(NextVersion nextVersion) => throw new NotImplementedException();
1212

1313
public SemanticVersionBuildMetaData CreateVersionBuildMetaData(ICommit? baseVersionSource) => this.metaData;
1414
}

src/GitVersion.Core/Extensions/EnumerableExtensions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,14 @@ public static class EnumerableExtensions
1818
var current = e.Current;
1919
return !e.MoveNext() ? current : default;
2020
}
21+
22+
public static T SingleOfType<T>(this IEnumerable source)
23+
{
24+
if (source == null)
25+
{
26+
throw new ArgumentNullException(nameof(source));
27+
}
28+
29+
return source.OfType<T>().Single();
30+
}
2131
}

src/GitVersion.Core/PublicAPI.Unshipped.txt

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -718,28 +718,19 @@ GitVersion.VersionCalculation.CommitMessageIncrementMode
718718
GitVersion.VersionCalculation.CommitMessageIncrementMode.Disabled = 1 -> GitVersion.VersionCalculation.CommitMessageIncrementMode
719719
GitVersion.VersionCalculation.CommitMessageIncrementMode.Enabled = 0 -> GitVersion.VersionCalculation.CommitMessageIncrementMode
720720
GitVersion.VersionCalculation.CommitMessageIncrementMode.MergeMessageOnly = 2 -> GitVersion.VersionCalculation.CommitMessageIncrementMode
721-
GitVersion.VersionCalculation.IContinuousDeliveryVersionCalculator
722-
GitVersion.VersionCalculation.IContinuousDeliveryVersionCalculator.Calculate(GitVersion.VersionCalculation.NextVersion! nextVersion) -> GitVersion.SemanticVersion!
723-
GitVersion.VersionCalculation.IContinuousDeploymentVersionCalculator
724-
GitVersion.VersionCalculation.IContinuousDeploymentVersionCalculator.Calculate(GitVersion.VersionCalculation.NextVersion! nextVersion) -> GitVersion.SemanticVersion!
725721
GitVersion.VersionCalculation.IEffectiveBranchConfigurationFinder
726722
GitVersion.VersionCalculation.IEffectiveBranchConfigurationFinder.GetConfigurations(GitVersion.IBranch! branch, GitVersion.Configuration.IGitVersionConfiguration! configuration) -> System.Collections.Generic.IEnumerable<GitVersion.Configuration.EffectiveBranchConfiguration!>!
727723
GitVersion.VersionCalculation.IIncrementStrategyFinder
728724
GitVersion.VersionCalculation.IIncrementStrategyFinder.DetermineIncrementedField(GitVersion.ICommit? currentCommit, GitVersion.VersionCalculation.BaseVersion! baseVersion, GitVersion.Configuration.EffectiveConfiguration! configuration) -> GitVersion.VersionField
729725
GitVersion.VersionCalculation.IIncrementStrategyFinder.GetIncrementForCommits(string? majorVersionBumpMessage, string? minorVersionBumpMessage, string? patchVersionBumpMessage, string? noBumpMessage, System.Collections.Generic.IEnumerable<GitVersion.ICommit!>! commits) -> GitVersion.VersionField?
730-
GitVersion.VersionCalculation.IMainlineVersionCalculator
731-
GitVersion.VersionCalculation.IMainlineVersionCalculator.CreateVersionBuildMetaData(GitVersion.ICommit? baseVersionSource) -> GitVersion.SemanticVersionBuildMetaData!
732-
GitVersion.VersionCalculation.IMainlineVersionCalculator.FindMainlineModeVersion(GitVersion.VersionCalculation.NextVersion! nextVersion) -> GitVersion.SemanticVersion!
733-
GitVersion.VersionCalculation.IManualDeploymentVersionCalculator
734-
GitVersion.VersionCalculation.IManualDeploymentVersionCalculator.Calculate(GitVersion.VersionCalculation.NextVersion! nextVersion) -> GitVersion.SemanticVersion!
735726
GitVersion.VersionCalculation.INextVersionCalculator
736727
GitVersion.VersionCalculation.INextVersionCalculator.FindVersion() -> GitVersion.VersionCalculation.NextVersion!
737-
GitVersion.VersionCalculation.ITrunkBasedVersionCalculator
738-
GitVersion.VersionCalculation.ITrunkBasedVersionCalculator.Calculate(GitVersion.VersionCalculation.NextVersion! nextVersion) -> GitVersion.SemanticVersion!
739728
GitVersion.VersionCalculation.IVariableProvider
740729
GitVersion.VersionCalculation.IVariableProvider.GetVariablesFor(GitVersion.SemanticVersion! semanticVersion, GitVersion.Configuration.EffectiveConfiguration! configuration, GitVersion.SemanticVersion? currentCommitTaggedVersion) -> GitVersion.OutputVariables.GitVersionVariables!
741730
GitVersion.VersionCalculation.IVersionFilter
742731
GitVersion.VersionCalculation.IVersionFilter.Exclude(GitVersion.VersionCalculation.BaseVersion! version, out string? reason) -> bool
732+
GitVersion.VersionCalculation.IVersionModeCalculator
733+
GitVersion.VersionCalculation.IVersionModeCalculator.Calculate(GitVersion.VersionCalculation.NextVersion! nextVersion) -> GitVersion.SemanticVersion!
743734
GitVersion.VersionCalculation.IVersionStrategy
744735
GitVersion.VersionCalculation.IVersionStrategy.GetBaseVersions(GitVersion.Configuration.EffectiveBranchConfiguration! configuration) -> System.Collections.Generic.IEnumerable<GitVersion.VersionCalculation.BaseVersion!>!
745736
GitVersion.VersionCalculation.NextVersion
@@ -834,6 +825,7 @@ static GitVersion.Extensions.CommonExtensions.NotNullOrEmpty(this string? value,
834825
static GitVersion.Extensions.CommonExtensions.NotNullOrWhitespace(this string? value, string! name = "") -> string!
835826
static GitVersion.Extensions.DictionaryExtensions.GetOrAdd<TKey, TValue>(this System.Collections.Generic.IDictionary<TKey, TValue>! dict, TKey key, System.Func<TValue>! getValue) -> TValue
836827
static GitVersion.Extensions.EnumerableExtensions.OnlyOrDefault<T>(this System.Collections.Generic.IEnumerable<T>! source) -> T?
828+
static GitVersion.Extensions.EnumerableExtensions.SingleOfType<T>(this System.Collections.IEnumerable! source) -> T
837829
static GitVersion.Extensions.GitExtensions.CreateGitLogArgs(int? maxCommits) -> string!
838830
static GitVersion.Extensions.GitExtensions.DumpGraph(string! workingDirectory, System.Action<string!>? writer = null, int? maxCommits = null) -> void
839831
static GitVersion.Extensions.ObjectExtensions.Deconstruct<TKey, TValue>(this System.Collections.Generic.KeyValuePair<TKey, TValue> kvp, out TKey key, out TValue value) -> void

src/GitVersion.Core/VersionCalculation/Abstractions/IContinuousDeliveryVersionCalculator.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/GitVersion.Core/VersionCalculation/Abstractions/IContinuousDeploymentVersionCalculator.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/GitVersion.Core/VersionCalculation/Abstractions/IMainlineVersionCalculator.cs

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/GitVersion.Core/VersionCalculation/Abstractions/IManualDeploymentVersionCalculator.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace GitVersion.VersionCalculation;
22

3-
public interface ITrunkBasedVersionCalculator
3+
public interface IVersionModeCalculator
44
{
55
SemanticVersion Calculate(NextVersion nextVersion);
66
}

src/GitVersion.Core/VersionCalculation/ContinuousDeliveryVersionCalculator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace GitVersion.VersionCalculation;
66

7-
internal sealed class ContinuousDeliveryVersionCalculator : NonTrunkBasedVersionCalculatorBase, IContinuousDeliveryVersionCalculator
7+
internal sealed class ContinuousDeliveryVersionCalculator : NonTrunkBasedVersionCalculatorBase, IVersionModeCalculator
88
{
99
public ContinuousDeliveryVersionCalculator(ILog log, IRepositoryStore repositoryStore, Lazy<GitVersionContext> versionContext)
1010
: base(log, repositoryStore, versionContext)

0 commit comments

Comments
 (0)