Skip to content

Commit 81dabba

Browse files
committed
Add null check to CommitCollection
1 parent 37dc680 commit 81dabba

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/GitVersion.LibGit2Sharp/Git/CommitCollection.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1+
using GitVersion.Extensions;
12
using LibGit2Sharp;
23

34
namespace GitVersion;
45

56
internal sealed class CommitCollection : ICommitCollection
67
{
78
private readonly ICommitLog innerCollection;
8-
internal CommitCollection(ICommitLog collection) => this.innerCollection = collection;
99

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();
1114

1215
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
1316

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+
1520
public IEnumerable<ICommit> QueryBy(CommitFilter commitFilter)
1621
{
1722
static object? GetReacheableFrom(object? item) =>
@@ -24,13 +29,7 @@ public IEnumerable<ICommit> QueryBy(CommitFilter commitFilter)
2429

2530
var includeReachableFrom = GetReacheableFrom(commitFilter.IncludeReachableFrom);
2631
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 };
3433
var commitLog = ((IQueryableCommitLog)this.innerCollection).QueryBy(filter);
3534
return new CommitCollection(commitLog);
3635
}

0 commit comments

Comments
 (0)