@@ -109,7 +109,7 @@ private static Regex TryGetRegexOrDefault(string? messageRegex, Regex defaultReg
109
109
? defaultRegex
110
110
: CompiledRegexCache . GetOrAdd ( messageRegex , pattern => new ( pattern , RegexOptions . Compiled | RegexOptions . IgnoreCase ) ) ;
111
111
112
- public IReadOnlyCollection < ICommit > GetCommitHistory (
112
+ private IReadOnlyCollection < ICommit > GetCommitHistory (
113
113
string ? tagPrefix , SemanticVersionFormat semanticVersionFormat , ICommit ? baseVersionSource , ICommit currentCommit , string ? label )
114
114
{
115
115
var targetShas = new Lazy < IReadOnlySet < string > > ( ( ) =>
@@ -121,23 +121,22 @@ public IReadOnlyCollection<ICommit> GetCommitHistory(
121
121
122
122
var commitLog = intermediateCommits . ToDictionary ( element => element . Id . Sha ) ;
123
123
124
- foreach ( var item in intermediateCommits . Reverse ( ) )
124
+ foreach ( var intermediateCommit in intermediateCommits . Reverse ( ) )
125
125
{
126
- if ( ! commitLog . ContainsKey ( item . Sha ) ) continue ;
126
+ if ( ! commitLog . ContainsKey ( intermediateCommit . Sha ) ) continue ;
127
127
128
- if ( targetShas . Value . Contains ( item . Sha ) )
128
+ if ( targetShas . Value . Contains ( intermediateCommit . Sha ) )
129
129
{
130
- void RemoveCommitFromHistory ( ICommit commit )
130
+ void RemoveCommitFromHistory ( ICommit commit , HashSet < ICommit > traversedCommits )
131
131
{
132
- if ( ! commitLog . ContainsKey ( commit . Sha ) ) return ;
132
+ if ( ! traversedCommits . Add ( commit ) || ! commitLog . Remove ( commit . Sha ) ) return ;
133
133
134
- commitLog . Remove ( commit . Sha ) ;
135
- foreach ( var item in commit . Parents )
134
+ foreach ( var parentCommit in commit . Parents )
136
135
{
137
- RemoveCommitFromHistory ( item ) ;
136
+ RemoveCommitFromHistory ( parentCommit , traversedCommits ) ;
138
137
}
139
138
}
140
- RemoveCommitFromHistory ( item ) ;
139
+ RemoveCommitFromHistory ( intermediateCommit , new HashSet < ICommit > ( ) ) ;
141
140
}
142
141
}
143
142
0 commit comments