Skip to content

Commit a484a48

Browse files
committed
Integrate code review remarks.
1 parent 2d1166e commit a484a48

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

src/GitVersion.Core/VersionCalculation/IncrementStrategyFinder.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,7 @@ private IReadOnlyCollection<ICommit> GetCommitHistory(string? tagPrefix, Semanti
106106
.ToHashSet()
107107
);
108108

109-
var intermediateCommits = this.repositoryStore.GetCommitLog(
110-
baseVersionSource: baseVersionSource,
111-
currentCommit: currentCommit,
112-
ignore: ignore
113-
);
109+
var intermediateCommits = this.repositoryStore.GetCommitLog(baseVersionSource, currentCommit, ignore);
114110
var commitLog = intermediateCommits.ToDictionary(element => element.Id.Sha);
115111

116112
foreach (var intermediateCommit in intermediateCommits.Reverse())

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using GitVersion.Core;
33
using GitVersion.Extensions;
44
using GitVersion.Logging;
5-
using static GitVersion.Core.RegexPatterns;
65

76
namespace GitVersion.VersionCalculation;
87

@@ -12,15 +11,16 @@ namespace GitVersion.VersionCalculation;
1211
/// Increments if the tag is not the current commit.
1312
/// </summary>
1413
internal sealed class TaggedCommitVersionStrategy(
15-
Lazy<GitVersionContext> contextLazy, ILog log,
14+
ILog log,
15+
Lazy<GitVersionContext> contextLazy,
1616
ITaggedSemanticVersionService taggedSemanticVersionService,
1717
IIncrementStrategyFinder incrementStrategyFinder)
1818
: IVersionStrategy
1919
{
20+
private readonly ILog log = log.NotNull();
2021
private readonly ITaggedSemanticVersionService taggedSemanticVersionService = taggedSemanticVersionService.NotNull();
2122
private readonly Lazy<GitVersionContext> contextLazy = contextLazy.NotNull();
2223
private readonly IIncrementStrategyFinder incrementStrategyFinder = incrementStrategyFinder.NotNull();
23-
private readonly ILog log = log.NotNull();
2424

2525
private GitVersionContext Context => contextLazy.Value;
2626

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

4545
var label = configuration.Value.GetBranchSpecificLabel(Context.CurrentBranch.Name, null);
4646

47-
SemanticVersion semanticVersionTreshold = new(0, 0, 0);
47+
var semanticVersionTreshold = SemanticVersion.Empty;
4848
List<SemanticVersionWithTag> alternativeSemanticVersionsWithTag = [];
49-
foreach (var semanticVersionWithTag in taggedSemanticVersions)
49+
foreach (var semanticVersion in taggedSemanticVersions)
5050
{
51-
if (!semanticVersionWithTag.Value.IsMatchForBranchSpecificLabel(label))
51+
if (!semanticVersion.Value.IsMatchForBranchSpecificLabel(label))
5252
{
53-
alternativeSemanticVersionsWithTag.Add(semanticVersionWithTag);
53+
alternativeSemanticVersionsWithTag.Add(semanticVersion);
5454
continue;
5555
}
5656

5757
var alternativeSemanticVersionMax = alternativeSemanticVersionsWithTag.Max()?.Value;
58-
var highestPossibleSemanticVersion = semanticVersionWithTag.Value.Increment(
58+
var highestPossibleSemanticVersion = semanticVersion.Value.Increment(
5959
VersionField.Major, null, forceIncrement: true, alternativeSemanticVersionMax
6060
);
6161
if (highestPossibleSemanticVersion.IsLessThan(semanticVersionTreshold, includePreRelease: false))
6262
{
6363
this.log.Info(
64-
$"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."
6565
);
6666
alternativeSemanticVersionsWithTag.Clear();
6767
continue;
6868
}
6969

70-
var baseVersionSource = semanticVersionWithTag.Tag.Commit;
70+
var baseVersionSource = semanticVersion.Tag.Commit;
7171
var increment = incrementStrategyFinder.DetermineIncrementedField(
7272
currentCommit: Context.CurrentCommit,
7373
baseVersionSource: baseVersionSource,
7474
shouldIncrement: true,
7575
configuration: configuration.Value,
7676
label: label
7777
);
78-
semanticVersionTreshold = semanticVersionWithTag.Value.Increment(increment, null, forceIncrement: true);
78+
semanticVersionTreshold = semanticVersion.Value.Increment(increment, null, forceIncrement: true);
7979

8080
yield return new BaseVersion(
81-
$"Git tag '{semanticVersionWithTag.Tag.Name.Friendly}'", semanticVersionWithTag.Value, baseVersionSource)
81+
$"Git tag '{semanticVersion.Tag.Name.Friendly}'", semanticVersion.Value, baseVersionSource)
8282
{
8383
Operator = new BaseVersionOperator
8484
{

0 commit comments

Comments
 (0)