@@ -342,30 +342,29 @@ public virtual Signature BuildSignature(DateTimeOffset now)
342
342
343
343
internal Signature BuildSignature ( DateTimeOffset now , bool shouldThrowIfNotFound )
344
344
{
345
- var name = Get < string > ( "user.name" ) ;
346
- var email = Get < string > ( "user.email" ) ;
345
+ var name = this . GetValueOrDefault < string > ( "user.name" ) ;
346
+ var email = this . GetValueOrDefault < string > ( "user.email" ) ;
347
347
348
- if ( shouldThrowIfNotFound )
348
+ if ( shouldThrowIfNotFound && ( string . IsNullOrEmpty ( name ) || string . IsNullOrEmpty ( email ) ) )
349
349
{
350
- if ( name == null || string . IsNullOrEmpty ( name . Value ) )
350
+ if ( string . IsNullOrEmpty ( name ) )
351
351
{
352
352
throw new LibGit2SharpException (
353
- "Can not find Name setting of the current user in Git configuration." ) ;
353
+ "Cannot find Name setting of the current user in Git configuration." ) ;
354
354
}
355
355
356
- if ( email == null || string . IsNullOrEmpty ( email . Value ) )
356
+ if ( string . IsNullOrEmpty ( email ) )
357
357
{
358
358
throw new LibGit2SharpException (
359
- "Can not find Email setting of the current user in Git configuration." ) ;
359
+ "Cannot find Email setting of the current user in Git configuration." ) ;
360
360
}
361
361
}
362
362
363
- var nameForSignature = name == null || string . IsNullOrEmpty ( name . Value ) ? "unknown" : name . Value ;
364
- var emailForSignature = email == null || string . IsNullOrEmpty ( email . Value )
365
- ? string . Format ( "{0}@{1}" , Environment . UserName , Environment . UserDomainName )
366
- : email . Value ;
367
-
368
- return new Signature ( nameForSignature , emailForSignature , now ) ;
363
+ return new Signature (
364
+ ! string . IsNullOrEmpty ( name ) ? name : "unknown" ,
365
+ ! string . IsNullOrEmpty ( email ) ? email : string . Format (
366
+ CultureInfo . InvariantCulture , "{0}@{1}" , Environment . UserName , Environment . UserDomainName ) ,
367
+ now ) ;
369
368
}
370
369
371
370
private ConfigurationSafeHandle Snapshot ( )
0 commit comments