Skip to content

Commit

Permalink
Check for null in BuildSignature
Browse files Browse the repository at this point in the history
Throw a more detailed exception indicating that one of the git config
variables is missing.
  • Loading branch information
geluk committed Nov 2, 2018
1 parent 363d68f commit 8ba00fc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pass-winmenu/src/ExternalPrograms/Git.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,15 @@ public Git(string repositoryPath, string nativeGitPath) : this(repositoryPath)

public BranchTrackingDetails GetTrackingDetails() => repo.Head.TrackingDetails;

private Signature BuildSignature() => repo.Config.BuildSignature(DateTimeOffset.Now);
private Signature BuildSignature()
{
var sig = repo.Config.BuildSignature(DateTimeOffset.Now);
if(sig == null){
throw new GitException("Could not build Git signature. Make sure 'user.name' and 'user.email' are configured for the repository.");
}
return sig;
}


/// <summary>
/// Rebases the current branch onto the branch it is tracking.
Expand All @@ -59,7 +67,7 @@ public void Rebase()
if (result.Status != RebaseStatus.Complete)
{
repo.Rebase.Abort();
throw new InvalidOperationException($"Could not rebase {head.FriendlyName} onto {head.TrackedBranch.FriendlyName}");
throw new GitException($"Could not rebase {head.FriendlyName} onto {head.TrackedBranch.FriendlyName}");
}
else if (result.CompletedStepCount > 0)
{
Expand Down

0 comments on commit 8ba00fc

Please sign in to comment.