Skip to content

Commit 2d1a235

Browse files
committed
Add null check to Remote
1 parent acb240f commit 2d1a235

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/GitVersion.LibGit2Sharp/Git/Remote.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using GitVersion.Extensions;
12
using GitVersion.Helpers;
23

34
namespace GitVersion;
@@ -9,13 +10,10 @@ internal sealed class Remote : IRemote
910

1011
private readonly LibGit2Sharp.Remote innerRemote;
1112

12-
internal Remote(LibGit2Sharp.Remote remote) => this.innerRemote = remote;
13+
internal Remote(LibGit2Sharp.Remote remote) => this.innerRemote = remote.NotNull();
1314

1415
public int CompareTo(IRemote other) => comparerHelper.Compare(this, other);
1516
public bool Equals(IRemote? other) => equalityHelper.Equals(this, other);
16-
public override bool Equals(object obj) => Equals((obj as IRemote));
17-
public override int GetHashCode() => equalityHelper.GetHashCode(this);
18-
public override string ToString() => Name;
1917
public string Name => this.innerRemote.Name;
2018
public string Url => this.innerRemote.Url;
2119

@@ -29,7 +27,10 @@ public IEnumerable<IRefSpec> RefSpecs
2927
: new RefSpecCollection((LibGit2Sharp.RefSpecCollection)refSpecs);
3028
}
3129
}
32-
public IEnumerable<IRefSpec> FetchRefSpecs => RefSpecs.Where(x => x.Direction == RefSpecDirection.Fetch);
3330

31+
public IEnumerable<IRefSpec> FetchRefSpecs => RefSpecs.Where(x => x.Direction == RefSpecDirection.Fetch);
3432
public IEnumerable<IRefSpec> PushRefSpecs => RefSpecs.Where(x => x.Direction == RefSpecDirection.Push);
33+
public override bool Equals(object obj) => Equals((obj as IRemote));
34+
public override int GetHashCode() => equalityHelper.GetHashCode(this);
35+
public override string ToString() => Name;
3536
}

0 commit comments

Comments
 (0)