зеркало из https://github.com/github/libgit2sharp.git
Introduce Identity type
This commit is contained in:
Родитель
930f63ce42
Коммит
964943bf9b
|
@ -6,7 +6,8 @@ namespace LibGit2Sharp.Tests.TestHelpers
|
|||
{
|
||||
public const string TemporaryReposPath = "TestRepos";
|
||||
public const string UnknownSha = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
|
||||
public static readonly Signature Signature = new Signature("A. U. Thor", "thor@valhalla.asgard.com", new DateTimeOffset(2011, 06, 16, 10, 58, 27, TimeSpan.FromHours(2)));
|
||||
public static readonly Identity Identity = new Identity("A. U. Thor", "thor@valhalla.asgard.com");
|
||||
public static readonly Signature Signature = new Signature(Identity, new DateTimeOffset(2011, 06, 16, 10, 58, 27, TimeSpan.FromHours(2)));
|
||||
|
||||
// Populate these to turn on live credential tests: set the
|
||||
// PrivateRepoUrl to the URL of a repository that requires
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
using LibGit2Sharp.Core;
|
||||
|
||||
namespace LibGit2Sharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the identity used when writing reflog entries.
|
||||
/// </summary>
|
||||
public sealed class Identity
|
||||
{
|
||||
private readonly string _name;
|
||||
private readonly string _email;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Identity"/> class.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="email">The email.</param>
|
||||
public Identity(string name, string email)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNullOrEmptyString(email, "email");
|
||||
Ensure.ArgumentDoesNotContainZeroByte(name, "name");
|
||||
Ensure.ArgumentDoesNotContainZeroByte(name, "email");
|
||||
|
||||
_name = name;
|
||||
_email = email;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the email.
|
||||
/// </summary>
|
||||
public string Email
|
||||
{
|
||||
get { return _email; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -80,6 +80,7 @@
|
|||
<Compile Include="EntryExistsException.cs" />
|
||||
<Compile Include="FetchOptionsBase.cs" />
|
||||
<Compile Include="IBelongToARepository.cs" />
|
||||
<Compile Include="Identity.cs" />
|
||||
<Compile Include="IndexNameEntryCollection.cs" />
|
||||
<Compile Include="ContentChangeStats.cs" />
|
||||
<Compile Include="BuiltInFeatures.cs" />
|
||||
|
|
|
@ -44,6 +44,20 @@ namespace LibGit2Sharp
|
|||
this.when = when;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Signature"/> class.
|
||||
/// </summary>
|
||||
/// <param name="identity">The identity.</param>
|
||||
/// <param name="when">The when.</param>
|
||||
public Signature(Identity identity, DateTimeOffset when)
|
||||
{
|
||||
Ensure.ArgumentNotNull(identity, "identity");
|
||||
|
||||
this.name = identity.Name;
|
||||
this.email = identity.Email;
|
||||
this.when = when;
|
||||
}
|
||||
|
||||
internal SignatureSafeHandle BuildHandle()
|
||||
{
|
||||
return Proxy.git_signature_new(name, email, when);
|
||||
|
|
Загрузка…
Ссылка в новой задаче