From d44fb2db2732205ade30ae4e3feeefbf0d11fba8 Mon Sep 17 00:00:00 2001 From: Artur Stolear Date: Thu, 14 Nov 2024 21:50:33 +0100 Subject: [PATCH] indent base version calculation --- .../NextVersionCalculator.cs | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/src/GitVersion.Core/VersionCalculation/VersionCalculators/NextVersionCalculator.cs b/src/GitVersion.Core/VersionCalculation/VersionCalculators/NextVersionCalculator.cs index 5111804989..8e4ebc4640 100644 --- a/src/GitVersion.Core/VersionCalculation/VersionCalculators/NextVersionCalculator.cs +++ b/src/GitVersion.Core/VersionCalculation/VersionCalculators/NextVersionCalculator.cs @@ -244,35 +244,36 @@ IEnumerable GetNextVersionsInternal() var effectiveBranchConfigurations = this.effectiveBranchConfigurationFinder.GetConfigurations(branch, configuration).ToArray(); foreach (var effectiveBranchConfiguration in effectiveBranchConfigurations) { - this.log.Info($"Calculating base versions for '{effectiveBranchConfiguration.Branch.Name}'"); - - var strategies = this.versionStrategies.ToList(); - var fallbackVersionStrategy = strategies.Find(element => element is FallbackVersionStrategy); - if (fallbackVersionStrategy is not null) - { - strategies.Remove(fallbackVersionStrategy); - strategies.Add(fallbackVersionStrategy); - } - - var atLeastOneBaseVersionReturned = false; - foreach (var versionStrategy in strategies) + using (this.log.IndentLog($"Calculating base versions for '{effectiveBranchConfiguration.Branch.Name}'")) { - if (atLeastOneBaseVersionReturned && versionStrategy is FallbackVersionStrategy) continue; + var strategies = this.versionStrategies.ToList(); + var fallbackVersionStrategy = strategies.Find(element => element is FallbackVersionStrategy); + if (fallbackVersionStrategy is not null) + { + strategies.Remove(fallbackVersionStrategy); + strategies.Add(fallbackVersionStrategy); + } - using (this.log.IndentLog($"[Using '{versionStrategy.GetType().Name}' strategy]")) + var atLeastOneBaseVersionReturned = false; + foreach (var versionStrategy in strategies) { - foreach (var baseVersion in versionStrategy.GetBaseVersions(effectiveBranchConfiguration)) + if (atLeastOneBaseVersionReturned && versionStrategy is FallbackVersionStrategy) continue; + + using (this.log.IndentLog($"[Using '{versionStrategy.GetType().Name}' strategy]")) { - log.Info(baseVersion.ToString()); - if (IncludeVersion(baseVersion, configuration.Ignore)) + foreach (var baseVersion in versionStrategy.GetBaseVersions(effectiveBranchConfiguration)) { - atLeastOneBaseVersionReturned = true; - - yield return new NextVersion( - incrementedVersion: baseVersion.GetIncrementedVersion(), - baseVersion: baseVersion, - configuration: effectiveBranchConfiguration - ); + log.Info(baseVersion.ToString()); + if (IncludeVersion(baseVersion, configuration.Ignore)) + { + atLeastOneBaseVersionReturned = true; + + yield return new NextVersion( + incrementedVersion: baseVersion.GetIncrementedVersion(), + baseVersion: baseVersion, + configuration: effectiveBranchConfiguration + ); + } } } }