22using GitVersion . Core ;
33using GitVersion . Extensions ;
44using GitVersion . Logging ;
5- using static GitVersion . Core . RegexPatterns ;
65
76namespace GitVersion . VersionCalculation ;
87
@@ -12,15 +11,16 @@ namespace GitVersion.VersionCalculation;
1211/// Increments if the tag is not the current commit.
1312/// </summary>
1413internal 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