Skip to content

Commit f7166e1

Browse files
committed
Pass a signature to LibGit2Sharp Commits. Closes #722
Related to libgit2/libgit2sharp#1163 Without a signature param, Commit throws an exception if no username is found, but BuildSignature returns "unknown" if no username is found. Fixes the crash by passing BuildSignature's results to each commit action.
1 parent cf3d1c9 commit f7166e1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Rubberduck.SourceControl/GitProvider.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,12 @@ public override IRepository InitVBAProject(string directory)
152152
repo.Stage(stat.FilePath);
153153
}
154154

155-
//If the user hasn't set up their name, this could throw an exception.
156-
//There may be other situations in which this could occur, but I'm not sure what they are right now.
157-
//Todo: consider a more specific exception that inherits from SourceControlException.
158155
try
159156
{
160-
repo.Commit("Intial Commit");
157+
//The default behavior of LibGit2Sharp.Repo.Commit is to throw an exception if no signature is found,
158+
// but BuildSignature() does not throw if a signature is not found, it returns "unknown" instead.
159+
// so we pass a signature that won't throw along to the commit.
160+
repo.Commit("Intial Commit", GetSignature());
161161
}
162162
catch(LibGit2SharpException ex)
163163
{
@@ -250,7 +250,10 @@ public override void Commit(string message)
250250
{
251251
try
252252
{
253-
_repo.Commit(message);
253+
//The default behavior of LibGit2Sharp.Repo.Commit is to throw an exception if no signature is found,
254+
// but BuildSignature() does not throw if a signature is not found, it returns "unknown" instead.
255+
// so we pass a signature that won't throw along to the commit.
256+
_repo.Commit(message, GetSignature());
254257
}
255258
catch (LibGit2SharpException ex)
256259
{

0 commit comments

Comments
 (0)