Skip to content

Commit e9c93b2

Browse files
committed
Add null check to RemoteCollection
1 parent 2d1a235 commit e9c93b2

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/GitVersion.LibGit2Sharp/Git/RemoteCollection.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1+
using GitVersion.Extensions;
2+
13
namespace GitVersion;
24

35
internal sealed class RemoteCollection : IRemoteCollection
46
{
57
private readonly LibGit2Sharp.RemoteCollection innerCollection;
6-
internal RemoteCollection(LibGit2Sharp.RemoteCollection collection) => this.innerCollection = collection;
78

8-
public IEnumerator<IRemote> GetEnumerator() => this.innerCollection.Select(reference => new Remote(reference)).GetEnumerator();
9+
internal RemoteCollection(LibGit2Sharp.RemoteCollection collection)
10+
=> this.innerCollection = collection.NotNull();
11+
12+
public IEnumerator<IRemote> GetEnumerator()
13+
=> this.innerCollection.Select(reference => new Remote(reference)).GetEnumerator();
14+
915
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
1016

1117
public IRemote? this[string name]
@@ -18,5 +24,7 @@ public IRemote? this[string name]
1824
}
1925

2026
public void Remove(string remoteName) => this.innerCollection.Remove(remoteName);
21-
public void Update(string remoteName, string refSpec) => this.innerCollection.Update(remoteName, r => r.FetchRefSpecs.Add(refSpec));
27+
28+
public void Update(string remoteName, string refSpec)
29+
=> this.innerCollection.Update(remoteName, r => r.FetchRefSpecs.Add(refSpec));
2230
}

0 commit comments

Comments
 (0)