This commit is contained in:
nulltoken 2015-03-17 19:32:22 +01:00
Родитель 930f63ce42
Коммит 964943bf9b
4 изменённых файлов: 62 добавлений и 1 удалений

Просмотреть файл

@ -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

45
LibGit2Sharp/Identity.cs Normal file
Просмотреть файл

@ -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);