@@ -6,11 +6,16 @@ namespace GitVersion.Git;
6
6
internal sealed class CommitCollection : ICommitCollection
7
7
{
8
8
private readonly ICommitLog innerCollection ;
9
+ private readonly Lazy < IReadOnlyCollection < ICommit > > commits ;
9
10
10
- internal CommitCollection ( ICommitLog collection ) => this . innerCollection = collection . NotNull ( ) ;
11
+ internal CommitCollection ( ICommitLog collection )
12
+ {
13
+ this . innerCollection = collection . NotNull ( ) ;
14
+ this . commits = new Lazy < IReadOnlyCollection < ICommit > > ( ( ) => this . innerCollection . Select ( commit => new Commit ( commit ) ) . ToArray ( ) ) ;
15
+ }
11
16
12
17
public IEnumerator < ICommit > GetEnumerator ( )
13
- => this . innerCollection . Select ( commit => new Commit ( commit ) ) . GetEnumerator ( ) ;
18
+ => this . commits . Value . GetEnumerator ( ) ;
14
19
15
20
IEnumerator IEnumerable . GetEnumerator ( ) => GetEnumerator ( ) ;
16
21
@@ -21,7 +26,13 @@ public IEnumerable<ICommit> QueryBy(CommitFilter commitFilter)
21
26
{
22
27
var includeReachableFrom = GetReacheableFrom ( commitFilter . IncludeReachableFrom ) ;
23
28
var excludeReachableFrom = GetReacheableFrom ( commitFilter . ExcludeReachableFrom ) ;
24
- var filter = new LibGit2Sharp . CommitFilter { IncludeReachableFrom = includeReachableFrom , ExcludeReachableFrom = excludeReachableFrom , FirstParentOnly = commitFilter . FirstParentOnly , SortBy = ( LibGit2Sharp . CommitSortStrategies ) commitFilter . SortBy } ;
29
+ var filter = new LibGit2Sharp . CommitFilter
30
+ {
31
+ IncludeReachableFrom = includeReachableFrom ,
32
+ ExcludeReachableFrom = excludeReachableFrom ,
33
+ FirstParentOnly = commitFilter . FirstParentOnly ,
34
+ SortBy = ( LibGit2Sharp . CommitSortStrategies ) commitFilter . SortBy
35
+ } ;
25
36
var commitLog = ( ( IQueryableCommitLog ) this . innerCollection ) . QueryBy ( filter ) ;
26
37
return new CommitCollection ( commitLog ) ;
27
38
0 commit comments