Skip to content

Commit

Permalink
Merge branch 'pascalberger-feature/null-ref-check' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
devlead committed Jan 25, 2020
2 parents e753e2e + 686d05f commit cb8d00e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
18 changes: 17 additions & 1 deletion src/Cake.Git/GitBranch.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using LibGit2Sharp;
using System;
using LibGit2Sharp;
// ReSharper disable MemberCanBePrivate.Global

namespace Cake.Git
Expand Down Expand Up @@ -49,6 +50,11 @@ public sealed class GitBranch
/// <param name="repository">The repository.</param>
public GitBranch(Repository repository)
{
if (repository == null)
{
throw new ArgumentNullException(nameof(repository));
}

CanonicalName = repository.Head.CanonicalName;
FriendlyName = repository.Head.FriendlyName;
Tip = new GitCommit(repository.Head.Tip);
Expand All @@ -64,6 +70,16 @@ public GitBranch(Repository repository)
/// <param name="branch">The branch.</param>
internal GitBranch(Repository repository, Branch branch)
{
if (repository == null)
{
throw new ArgumentNullException(nameof(repository));
}

if (branch == null)
{
throw new ArgumentNullException(nameof(branch));
}

CanonicalName = branch.CanonicalName;
FriendlyName = branch.FriendlyName;
Tip = new GitCommit(branch.Tip);
Expand Down
2 changes: 1 addition & 1 deletion src/Cake.Git/GitCommit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ internal GitCommit(Commit commit)
{
if (commit == null)
{
throw new ArgumentException("Source commit can't be null.", nameof(commit));
throw new ArgumentNullException(nameof(commit));
}

Sha = commit.Sha;
Expand Down
6 changes: 6 additions & 0 deletions src/Cake.Git/GitDiffFile.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using LibGit2Sharp;
// ReSharper disable MemberCanBePrivate.Global

Expand Down Expand Up @@ -35,6 +36,11 @@ public class GitDiffFile

internal GitDiffFile(TreeEntryChanges change)
{
if (change == null)
{
throw new ArgumentNullException(nameof(change));
}

Path = change.Path;
OldPath = change.OldPath;
Status = (GitChangeKind)change.Status;
Expand Down

0 comments on commit cb8d00e

Please sign in to comment.