1
+ using GitVersion . Extensions ;
1
2
using LibGit2Sharp ;
2
3
3
4
namespace GitVersion ;
4
5
5
6
internal sealed class CommitCollection : ICommitCollection
6
7
{
7
8
private readonly ICommitLog innerCollection ;
8
- internal CommitCollection ( ICommitLog collection ) => this . innerCollection = collection ;
9
9
10
- public IEnumerator < ICommit > GetEnumerator ( ) => this . innerCollection . Select ( commit => new Commit ( commit ) ) . GetEnumerator ( ) ;
10
+ internal CommitCollection ( ICommitLog collection ) => this . innerCollection = collection . NotNull ( ) ;
11
+
12
+ public IEnumerator < ICommit > GetEnumerator ( )
13
+ => this . innerCollection . Select ( commit => new Commit ( commit ) ) . GetEnumerator ( ) ;
11
14
12
15
IEnumerator IEnumerable . GetEnumerator ( ) => GetEnumerator ( ) ;
13
16
14
- public IEnumerable < ICommit > GetCommitsPriorTo ( DateTimeOffset olderThan ) => this . SkipWhile ( c => c . When > olderThan ) ;
17
+ public IEnumerable < ICommit > GetCommitsPriorTo ( DateTimeOffset olderThan )
18
+ => this . SkipWhile ( c => c . When > olderThan ) ;
19
+
15
20
public IEnumerable < ICommit > QueryBy ( CommitFilter commitFilter )
16
21
{
17
22
static object ? GetReacheableFrom ( object ? item ) =>
@@ -24,13 +29,7 @@ public IEnumerable<ICommit> QueryBy(CommitFilter commitFilter)
24
29
25
30
var includeReachableFrom = GetReacheableFrom ( commitFilter . IncludeReachableFrom ) ;
26
31
var excludeReachableFrom = GetReacheableFrom ( commitFilter . ExcludeReachableFrom ) ;
27
- var filter = new LibGit2Sharp . CommitFilter
28
- {
29
- IncludeReachableFrom = includeReachableFrom ,
30
- ExcludeReachableFrom = excludeReachableFrom ,
31
- FirstParentOnly = commitFilter . FirstParentOnly ,
32
- SortBy = ( LibGit2Sharp . CommitSortStrategies ) commitFilter . SortBy
33
- } ;
32
+ var filter = new LibGit2Sharp . CommitFilter { IncludeReachableFrom = includeReachableFrom , ExcludeReachableFrom = excludeReachableFrom , FirstParentOnly = commitFilter . FirstParentOnly , SortBy = ( LibGit2Sharp . CommitSortStrategies ) commitFilter . SortBy } ;
34
33
var commitLog = ( ( IQueryableCommitLog ) this . innerCollection ) . QueryBy ( filter ) ;
35
34
return new CommitCollection ( commitLog ) ;
36
35
}
0 commit comments