Skip to content

Commit 864b630

Browse files
committed
Integrate code review remarks.
1 parent 065d6f7 commit 864b630

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/TaggedCommitVersionStrategy.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ namespace GitVersion.VersionCalculation;
1111
/// Increments if the tag is not the current commit.
1212
/// </summary>
1313
internal sealed class TaggedCommitVersionStrategy(
14-
Lazy<GitVersionContext> contextLazy, ILog log,
14+
ILog log,
15+
Lazy<GitVersionContext> contextLazy,
1516
ITaggedSemanticVersionService taggedSemanticVersionService,
1617
IIncrementStrategyFinder incrementStrategyFinder)
1718
: IVersionStrategy
1819
{
20+
private readonly ILog log = log.NotNull();
1921
private readonly ITaggedSemanticVersionService taggedSemanticVersionService = taggedSemanticVersionService.NotNull();
2022
private readonly Lazy<GitVersionContext> contextLazy = contextLazy.NotNull();
2123
private readonly IIncrementStrategyFinder incrementStrategyFinder = incrementStrategyFinder.NotNull();
22-
private readonly ILog log = log.NotNull();
2324

2425
private GitVersionContext Context => contextLazy.Value;
2526

@@ -43,41 +44,41 @@ private IEnumerable<BaseVersion> GetBaseVersionsInternal(EffectiveBranchConfigur
4344

4445
var label = configuration.Value.GetBranchSpecificLabel(Context.CurrentBranch.Name, null);
4546

46-
SemanticVersion semanticVersionTreshold = new(0, 0, 0);
47+
var semanticVersionTreshold = SemanticVersion.Empty;
4748
List<SemanticVersionWithTag> alternativeSemanticVersionsWithTag = [];
48-
foreach (var semanticVersionWithTag in taggedSemanticVersions)
49+
foreach (var semanticVersion in taggedSemanticVersions)
4950
{
50-
if (!semanticVersionWithTag.Value.IsMatchForBranchSpecificLabel(label))
51+
if (!semanticVersion.Value.IsMatchForBranchSpecificLabel(label))
5152
{
52-
alternativeSemanticVersionsWithTag.Add(semanticVersionWithTag);
53+
alternativeSemanticVersionsWithTag.Add(semanticVersion);
5354
continue;
5455
}
5556

5657
var alternativeSemanticVersionMax = alternativeSemanticVersionsWithTag.Max()?.Value;
57-
var highestPossibleSemanticVersion = semanticVersionWithTag.Value.Increment(
58+
var highestPossibleSemanticVersion = semanticVersion.Value.Increment(
5859
VersionField.Major, null, forceIncrement: true, alternativeSemanticVersionMax
5960
);
6061
if (highestPossibleSemanticVersion.IsLessThan(semanticVersionTreshold, includePreRelease: false))
6162
{
6263
this.log.Info(
63-
$"The tag '{semanticVersionWithTag.Value}' is skipped because it will never be higher than other tags."
64+
$"The tag '{semanticVersion.Value}' is skipped because it provides a lower base version than other tags."
6465
);
6566
alternativeSemanticVersionsWithTag.Clear();
6667
continue;
6768
}
6869

69-
var baseVersionSource = semanticVersionWithTag.Tag.Commit;
70+
var baseVersionSource = semanticVersion.Tag.Commit;
7071
var increment = incrementStrategyFinder.DetermineIncrementedField(
7172
currentCommit: Context.CurrentCommit,
7273
baseVersionSource: baseVersionSource,
7374
shouldIncrement: true,
7475
configuration: configuration.Value,
7576
label: label
7677
);
77-
semanticVersionTreshold = semanticVersionWithTag.Value.Increment(increment, null, forceIncrement: true);
78+
semanticVersionTreshold = semanticVersion.Value.Increment(increment, null, forceIncrement: true);
7879

7980
yield return new BaseVersion(
80-
$"Git tag '{semanticVersionWithTag.Tag.Name.Friendly}'", semanticVersionWithTag.Value, baseVersionSource)
81+
$"Git tag '{semanticVersion.Tag.Name.Friendly}'", semanticVersion.Value, baseVersionSource)
8182
{
8283
Operator = new BaseVersionOperator
8384
{

0 commit comments

Comments
 (0)