@@ -15,6 +15,7 @@ public enum CommitMessageIncrementMode
15
15
16
16
public static class IncrementStrategyFinder
17
17
{
18
+ private static List < Commit > intermediateCommitCache ;
18
19
public const string DefaultMajorPattern = @"\+semver:\s?(breaking|major)" ;
19
20
public const string DefaultMinorPattern = @"\+semver:\s?(feature|minor)" ;
20
21
public const string DefaultPatchPattern = @"\+semver:\s?(fix|patch)" ;
@@ -53,7 +54,7 @@ public static class IncrementStrategyFinder
53
54
return null ;
54
55
}
55
56
56
- var commits = GetIntermediateCommits ( context . Repository , baseVersion . BaseVersionSource , context . CurrentCommit ) ;
57
+ var commits = GetIntermediateCommits ( context . Repository , baseVersion . BaseVersionSource , context . CurrentCommit , context . CurrentBranch ) ;
57
58
58
59
if ( context . Configuration . CommitMessageIncrementing == CommitMessageIncrementMode . MergeMessageOnly )
59
60
{
@@ -78,16 +79,34 @@ public static class IncrementStrategyFinder
78
79
return null ;
79
80
}
80
81
81
- private static IEnumerable < Commit > GetIntermediateCommits ( IRepository repo , Commit baseCommit , Commit headCommit )
82
+ private static IEnumerable < Commit > GetIntermediateCommits ( IRepository repo , Commit baseCommit , Commit headCommit , Branch currentBranch )
82
83
{
83
- var filter = new CommitFilter
84
+ if ( baseCommit == null ) yield break ;
85
+
86
+ if ( intermediateCommitCache == null )
87
+ {
88
+ var filter = new CommitFilter
89
+ {
90
+ Since = currentBranch . Tip ,
91
+ Until = baseCommit ,
92
+ SortBy = CommitSortStrategies . Topological | CommitSortStrategies . Reverse
93
+ } ;
94
+
95
+ intermediateCommitCache = repo . Commits . QueryBy ( filter ) . ToList ( ) ;
96
+ }
97
+
98
+ var found = false ;
99
+ foreach ( var commit in intermediateCommitCache )
84
100
{
85
- Since = headCommit ,
86
- Until = baseCommit ,
87
- SortBy = CommitSortStrategies . Topological | CommitSortStrategies . Reverse
88
- } ;
101
+ if ( commit . Sha == baseCommit . Sha )
102
+ found = true ;
103
+
104
+ if ( found )
105
+ yield return commit ;
89
106
90
- return repo . Commits . QueryBy ( filter ) ;
107
+ if ( commit . Sha == headCommit . Sha )
108
+ yield break ;
109
+ }
91
110
}
92
111
93
112
private static VersionField ? FindIncrementFromMessage ( string message , Regex major , Regex minor , Regex patch )
0 commit comments