@@ -40,7 +40,7 @@ public VersionField DetermineIncrementedField(
40
40
configuration . NotNull ( ) ;
41
41
42
42
var commitMessageIncrement = FindCommitMessageIncrement (
43
- configuration , baseVersion . BaseVersionSource , currentCommit , label ) ;
43
+ configuration , baseVersion , currentCommit , label ) ;
44
44
45
45
var defaultIncrement = configuration . Increment . ToVersionField ( ) ;
46
46
@@ -81,31 +81,38 @@ public VersionField DetermineIncrementedField(
81
81
}
82
82
83
83
private VersionField ? FindCommitMessageIncrement (
84
- EffectiveConfiguration configuration , ICommit ? baseCommit , ICommit ? currentCommit , string ? label )
84
+ EffectiveConfiguration configuration , BaseVersion baseVersion , ICommit ? currentCommit , string ? label )
85
85
{
86
86
if ( configuration . CommitMessageIncrementing == CommitMessageIncrementMode . Disabled )
87
87
{
88
88
return null ;
89
89
}
90
90
91
+ var baseCommit = baseVersion . BaseVersionSource ;
92
+
91
93
//get tags with valid version - depends on configuration (see #3757)
92
94
var targetShas = new Lazy < IReadOnlySet < string > > ( ( ) =>
93
95
this . taggedSemanticVersionRepository . GetTaggedSemanticVersions ( configuration . TagPrefix , configuration . SemanticVersionFormat )
94
- . SelectMany ( _ => _ ) . Where ( _ => _ . Value . IsMatchForBranchSpecificLabel ( label ) ) . Select ( _ => _ . Tag . TargetSha ) . ToHashSet ( )
96
+ . SelectMany ( _ => _ ) . Where ( _ => _ . Value . IsMatchForBranchSpecificLabel ( label ) ) . Select ( _ => _ . Tag . TargetSha ) . ToHashSet ( )
95
97
) ;
96
98
97
- var commits = GetIntermediateCommits ( baseCommit , currentCommit ) ;
99
+ var targetTags = this . taggedSemanticVersionRepository
100
+ . GetTaggedSemanticVersions ( configuration . TagPrefix , configuration . SemanticVersionFormat )
101
+ . SelectMany ( _ => _ ) . Where ( element => element . Value . IsMatchForBranchSpecificLabel ( label )
102
+ && element . Value . CompareTo ( baseVersion . GetSemanticVersion ( ) ) == 0 ) . Select ( _ => _ . Tag . TargetSha ) . ToHashSet ( ) ;
103
+
104
+ var intermediateCommits = GetIntermediateCommits ( baseCommit , currentCommit ) ;
98
105
// consider commit messages since latest tag only (see #3071)
99
- commits = commits
106
+ var commits = intermediateCommits
100
107
. Reverse ( )
101
- . TakeWhile ( x => ! targetShas . Value . Contains ( x . Sha ) )
108
+ . TakeWhile ( x => baseCommit != x )
109
+ . Where ( element => ! targetShas . Value . Contains ( element . Sha ) )
102
110
. Reverse ( ) ;
103
111
104
112
if ( configuration . CommitMessageIncrementing == CommitMessageIncrementMode . MergeMessageOnly )
105
113
{
106
114
commits = commits . Where ( c => c . Parents . Count ( ) > 1 ) ;
107
115
}
108
-
109
116
return GetIncrementForCommits (
110
117
majorVersionBumpMessage : configuration . MajorVersionBumpMessage ,
111
118
minorVersionBumpMessage : configuration . MinorVersionBumpMessage ,
0 commit comments