@@ -112,7 +112,7 @@ private static Regex TryGetRegexOrDefault(string? messageRegex, Regex defaultReg
112
112
private IReadOnlyCollection < ICommit > GetCommitHistory (
113
113
string ? tagPrefix , SemanticVersionFormat semanticVersionFormat , ICommit ? baseVersionSource , ICommit currentCommit , string ? label )
114
114
{
115
- var targetShas = new Lazy < IReadOnlySet < string > > ( ( ) =>
115
+ var targetShas = new Lazy < HashSet < string > > ( ( ) =>
116
116
this . taggedSemanticVersionRepository . GetTaggedSemanticVersions ( tagPrefix , semanticVersionFormat )
117
117
. SelectMany ( _ => _ ) . Where ( _ => _ . Value . IsMatchForBranchSpecificLabel ( label ) ) . Select ( _ => _ . Tag . TargetSha ) . ToHashSet ( )
118
118
) ;
@@ -123,20 +123,21 @@ private IReadOnlyCollection<ICommit> GetCommitHistory(
123
123
124
124
foreach ( var intermediateCommit in intermediateCommits . Reverse ( ) )
125
125
{
126
- if ( ! commitLog . ContainsKey ( intermediateCommit . Sha ) ) continue ;
127
-
128
- if ( targetShas . Value . Contains ( intermediateCommit . Sha ) )
126
+ if ( targetShas . Value . Contains ( intermediateCommit . Sha ) && commitLog . Remove ( intermediateCommit . Sha ) )
129
127
{
130
- void RemoveCommitFromHistory ( ICommit commit , HashSet < ICommit > traversedCommits )
128
+ var parentCommits = intermediateCommit . Parents . ToList ( ) ;
129
+ while ( parentCommits . Count != 0 )
131
130
{
132
- if ( ! traversedCommits . Add ( commit ) || ! commitLog . Remove ( commit . Sha ) ) return ;
133
-
134
- foreach ( var parentCommit in commit . Parents )
131
+ List < ICommit > temporaryList = new ( ) ;
132
+ foreach ( var parentCommit in parentCommits )
135
133
{
136
- RemoveCommitFromHistory ( parentCommit , traversedCommits ) ;
134
+ if ( commitLog . Remove ( parentCommit . Sha ) )
135
+ {
136
+ temporaryList . AddRange ( parentCommit . Parents ) ;
137
+ }
137
138
}
139
+ parentCommits = temporaryList ;
138
140
}
139
- RemoveCommitFromHistory ( intermediateCommit , new HashSet < ICommit > ( ) ) ;
140
141
}
141
142
}
142
143
0 commit comments