Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2015-03-16 22:50:16 +0300
committernulltoken <emeric.fermas@gmail.com>2015-03-17 21:58:37 +0300
commitd8a04a467baf2ec0139d214f798f5c0a82dd25cb (patch)
treefb7adb551288e7934a1bd1055fe1188e649ca35a /LibGit2Sharp.Tests
parent964943bf9bed4da87a08befa7df30b8e2d77373d (diff)
Update libgit2 to 9bbc8f3
https://github.com/libgit2/libgit2/compare/e0902fb...9bbc8f3
Diffstat (limited to 'LibGit2Sharp.Tests')
-rw-r--r--LibGit2Sharp.Tests/BranchFixture.cs89
-rw-r--r--LibGit2Sharp.Tests/CheckoutFixture.cs14
-rw-r--r--LibGit2Sharp.Tests/CommitFixture.cs18
-rw-r--r--LibGit2Sharp.Tests/PushFixture.cs7
-rw-r--r--LibGit2Sharp.Tests/ReferenceFixture.cs71
-rw-r--r--LibGit2Sharp.Tests/ReflogFixture.cs39
-rw-r--r--LibGit2Sharp.Tests/ResetHeadFixture.cs38
-rw-r--r--LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs7
8 files changed, 174 insertions, 109 deletions
diff --git a/LibGit2Sharp.Tests/BranchFixture.cs b/LibGit2Sharp.Tests/BranchFixture.cs
index c39a9658..225ea4ee 100644
--- a/LibGit2Sharp.Tests/BranchFixture.cs
+++ b/LibGit2Sharp.Tests/BranchFixture.cs
@@ -18,7 +18,7 @@ namespace LibGit2Sharp.Tests
public void CanCreateBranch(string name)
{
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
@@ -39,8 +39,10 @@ namespace LibGit2Sharp.Tests
Assert.NotNull(repo.Branches.SingleOrDefault(p => p.Name.Normalize() == name));
AssertRefLogEntry(repo, newBranch.CanonicalName,
+ "branch: Created from " + committish,
+ null,
newBranch.Tip.Id,
- "branch: Created from " + committish);
+ Constants.Identity, DateTimeOffset.Now);
repo.Branches.Remove(newBranch.Name);
Assert.Null(repo.Branches[name]);
@@ -86,7 +88,7 @@ namespace LibGit2Sharp.Tests
public void CanCreateBranchUsingAbbreviatedSha()
{
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions{ Identity = Constants.Identity }))
{
EnableRefLog(repo);
@@ -98,8 +100,10 @@ namespace LibGit2Sharp.Tests
Assert.Equal("be3563ae3f795b2b4353bcce3a527ad0a4f7f644", newBranch.Tip.Sha);
AssertRefLogEntry(repo, newBranch.CanonicalName,
+ "branch: Created from " + committish,
+ null,
newBranch.Tip.Id,
- "branch: Created from " + committish);
+ Constants.Identity, DateTimeOffset.Now);
}
}
@@ -109,7 +113,7 @@ namespace LibGit2Sharp.Tests
public void CanCreateBranchFromImplicitHead(string headCommitOrBranchSpec)
{
string path = SandboxStandardTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
@@ -126,8 +130,10 @@ namespace LibGit2Sharp.Tests
Assert.NotNull(repo.Branches.SingleOrDefault(p => p.Name == name));
AssertRefLogEntry(repo, newBranch.CanonicalName,
+ "branch: Created from " + headCommitOrBranchSpec,
+ null,
newBranch.Tip.Id,
- "branch: Created from " + headCommitOrBranchSpec);
+ Constants.Identity, DateTimeOffset.Now);
}
}
@@ -137,7 +143,7 @@ namespace LibGit2Sharp.Tests
public void CanCreateBranchFromExplicitHead(string headCommitOrBranchSpec)
{
string path = SandboxStandardTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
@@ -149,8 +155,10 @@ namespace LibGit2Sharp.Tests
Assert.Equal("32eab9cb1f450b5fe7ab663462b77d7f4b703344", newBranch.Tip.Sha);
AssertRefLogEntry(repo, newBranch.CanonicalName,
+ "branch: Created from HEAD",
+ null,
newBranch.Tip.Id,
- "branch: Created from " + headCommitOrBranchSpec);
+ Constants.Identity, DateTimeOffset.Now);
}
}
@@ -158,7 +166,7 @@ namespace LibGit2Sharp.Tests
public void CanCreateBranchFromCommit()
{
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
@@ -169,8 +177,10 @@ namespace LibGit2Sharp.Tests
Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", newBranch.Tip.Sha);
AssertRefLogEntry(repo, newBranch.CanonicalName,
+ "branch: Created from " + newBranch.Tip.Sha,
+ null,
newBranch.Tip.Id,
- "branch: Created from " + newBranch.Tip.Sha);
+ Constants.Identity, DateTimeOffset.Now);
}
}
@@ -178,7 +188,7 @@ namespace LibGit2Sharp.Tests
public void CanCreateBranchFromRevparseSpec()
{
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
@@ -190,8 +200,10 @@ namespace LibGit2Sharp.Tests
Assert.Equal("9fd738e8f7967c078dceed8190330fc8648ee56a", newBranch.Tip.Sha);
AssertRefLogEntry(repo, newBranch.CanonicalName,
+ "branch: Created from " + committish,
+ null,
newBranch.Tip.Id,
- "branch: Created from " + committish);
+ Constants.Identity, DateTimeOffset.Now);
}
}
@@ -201,7 +213,7 @@ namespace LibGit2Sharp.Tests
public void CreatingABranchFromATagPeelsToTheCommit(string committish)
{
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
@@ -212,8 +224,10 @@ namespace LibGit2Sharp.Tests
Assert.Equal("e90810b8df3e80c413d903f631643c716887138d", newBranch.Tip.Sha);
AssertRefLogEntry(repo, newBranch.CanonicalName,
+ "branch: Created from " + committish,
+ null,
newBranch.Tip.Id,
- "branch: Created from " + committish);
+ Constants.Identity, DateTimeOffset.Now);
}
}
@@ -559,7 +573,7 @@ namespace LibGit2Sharp.Tests
{
Branch master = repo.Branches["master"];
const string logMessage = "update target message";
- repo.Refs.UpdateTarget("refs/remotes/origin/master", "origin/test", Constants.Signature, logMessage);
+ repo.Refs.UpdateTarget("refs/remotes/origin/master", "origin/test", logMessage);
Assert.True(master.IsTracking);
Assert.NotNull(master.TrackedBranch);
@@ -964,7 +978,7 @@ namespace LibGit2Sharp.Tests
public void CanRenameABranch()
{
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
@@ -980,8 +994,10 @@ namespace LibGit2Sharp.Tests
Assert.NotNull(repo.Branches["br3"]);
AssertRefLogEntry(repo, newBranch.CanonicalName,
+ string.Format("branch: renamed {0} to {1}", br2.CanonicalName, newBranch.CanonicalName),
+ br2.Tip.Id,
newBranch.Tip.Id,
- string.Format("branch: renamed {0} to {1}", br2.CanonicalName, newBranch.CanonicalName));
+ Constants.Identity, DateTimeOffset.Now);
}
}
@@ -999,7 +1015,7 @@ namespace LibGit2Sharp.Tests
public void CanRenameABranchWhileOverwritingAnExistingOne()
{
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
@@ -1021,9 +1037,10 @@ namespace LibGit2Sharp.Tests
Assert.Equal(br2.Tip, newTest.Tip);
AssertRefLogEntry(repo, newBranch.CanonicalName,
- newBranch.Tip.Id,
string.Format("branch: renamed {0} to {1}", br2.CanonicalName, newBranch.CanonicalName),
- test.Tip.Id);
+ br2.Tip.Id,
+ newTest.Tip.Id,
+ Constants.Identity, DateTimeOffset.Now);
}
}
@@ -1129,15 +1146,22 @@ namespace LibGit2Sharp.Tests
public void CreatingABranchIncludesTheCorrectReflogEntries()
{
string path = SandboxStandardTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
var branch = repo.Branches.Add("foo", repo.Head.Tip);
- AssertRefLogEntry(repo, branch.CanonicalName, branch.Tip.Id,
- string.Format("branch: Created from {0}", repo.Head.Tip.Sha));
- branch = repo.Branches.Add("bar", repo.Head.Tip, null, "BAR");
- AssertRefLogEntry(repo, branch.CanonicalName, repo.Head.Tip.Id, "BAR");
+ AssertRefLogEntry(repo, branch.CanonicalName,
+ string.Format("branch: Created from {0}", repo.Head.Tip.Sha),
+ null, branch.Tip.Id,
+ Constants.Identity, DateTimeOffset.Now);
+
+ branch = repo.Branches.Add("bar", repo.Head.Tip);
+
+ AssertRefLogEntry(repo, branch.CanonicalName,
+ "branch: Created from " + repo.Head.Tip.Sha,
+ null, repo.Head.Tip.Id,
+ Constants.Identity, DateTimeOffset.Now);
}
}
@@ -1145,16 +1169,19 @@ namespace LibGit2Sharp.Tests
public void RenamingABranchIncludesTheCorrectReflogEntries()
{
string path = SandboxStandardTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
var master = repo.Branches["master"];
var newMaster = repo.Branches.Rename(master, "new-master");
- AssertRefLogEntry(repo, newMaster.CanonicalName, newMaster.Tip.Id,
- "branch: renamed refs/heads/master to refs/heads/new-master");
-
- newMaster = repo.Branches.Rename(newMaster, "new-master2", null, "MOVE");
- AssertRefLogEntry(repo, newMaster.CanonicalName, newMaster.Tip.Id, "MOVE");
+ AssertRefLogEntry(repo, newMaster.CanonicalName, "branch: renamed refs/heads/master to refs/heads/new-master",
+ newMaster.Tip.Id, newMaster.Tip.Id,
+ Constants.Identity, DateTimeOffset.Now);
+
+ var newMaster2 = repo.Branches.Rename(newMaster, "new-master2");
+ AssertRefLogEntry(repo, newMaster2.CanonicalName, "branch: renamed refs/heads/new-master to refs/heads/new-master2",
+ newMaster.Tip.Id, newMaster2.Tip.Id,
+ Constants.Identity, DateTimeOffset.Now);
}
}
}
diff --git a/LibGit2Sharp.Tests/CheckoutFixture.cs b/LibGit2Sharp.Tests/CheckoutFixture.cs
index 77809d58..448ae2c3 100644
--- a/LibGit2Sharp.Tests/CheckoutFixture.cs
+++ b/LibGit2Sharp.Tests/CheckoutFixture.cs
@@ -779,7 +779,7 @@ namespace LibGit2Sharp.Tests
public void CheckoutBranchFromDetachedHead()
{
string path = SandboxStandardTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions{ Identity = Constants.Identity }))
{
// Set the working directory to the current head
ResetAndCleanWorkingDirectory(repo);
@@ -789,12 +789,12 @@ namespace LibGit2Sharp.Tests
Assert.True(repo.Info.IsHeadDetached);
- Branch newHead = repo.Checkout(repo.Branches["master"], Constants.Signature);
+ Branch newHead = repo.Checkout(repo.Branches["master"]);
// Assert reflog entry is created
- AssertRefLogEntry(repo, "HEAD", newHead.Tip.Id,
+ AssertRefLogEntry(repo, "HEAD",
string.Format("checkout: moving from {0} to {1}", initialHead.Tip.Sha, newHead.Name),
- initialHead.Tip.Id, Constants.Signature);
+ initialHead.Tip.Id, newHead.Tip.Id, Constants.Identity, DateTimeOffset.Now);
}
}
@@ -847,7 +847,7 @@ namespace LibGit2Sharp.Tests
public void CheckoutCurrentReference()
{
string path = SandboxStandardTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
Branch master = repo.Branches["master"];
Assert.True(master.IsCurrentRepositoryHead);
@@ -866,8 +866,8 @@ namespace LibGit2Sharp.Tests
repo.Checkout(master.Tip.Sha);
Assert.True(repo.Info.IsHeadDetached);
- AssertRefLogEntry(repo, "HEAD", master.Tip.Id,
- string.Format("checkout: moving from master to {0}", master.Tip.Sha), master.Tip.Id);
+ AssertRefLogEntry(repo, "HEAD",
+ string.Format("checkout: moving from master to {0}", master.Tip.Sha), master.Tip.Id, master.Tip.Id, Constants.Identity, DateTimeOffset.Now);
// Checkout detached "HEAD" => nothing should happen
reflogEntriesCount = repo.Refs.Log(repo.Refs.Head).Count();
diff --git a/LibGit2Sharp.Tests/CommitFixture.cs b/LibGit2Sharp.Tests/CommitFixture.cs
index e86d7da3..18fec45b 100644
--- a/LibGit2Sharp.Tests/CommitFixture.cs
+++ b/LibGit2Sharp.Tests/CommitFixture.cs
@@ -661,7 +661,9 @@ namespace LibGit2Sharp.Tests
{
string repoPath = InitNewRepository();
- using (var repo = new Repository(repoPath))
+ var identity = Constants.Identity;
+
+ using (var repo = new Repository(repoPath, new RepositoryOptions { Identity = identity }))
{
string dir = repo.Info.Path;
Assert.True(Path.IsPathRooted(dir));
@@ -691,7 +693,13 @@ namespace LibGit2Sharp.Tests
// Assert a reflog entry is created on HEAD
Assert.Equal(1, repo.Refs.Log("HEAD").Count());
var reflogEntry = repo.Refs.Log("HEAD").First();
- Assert.Equal(author, reflogEntry.Committer);
+
+ Assert.Equal(identity.Name, reflogEntry.Committer.Name);
+ Assert.Equal(identity.Email, reflogEntry.Committer.Email);
+
+ var now = DateTimeOffset.Now;
+ Assert.InRange(reflogEntry.Committer.When, now - TimeSpan.FromSeconds(1), now);
+
Assert.Equal(commit.Id, reflogEntry.To);
Assert.Equal(ObjectId.Zero, reflogEntry.From);
Assert.Equal(string.Format("commit (initial): {0}", shortMessage), reflogEntry.Message);
@@ -805,7 +813,7 @@ namespace LibGit2Sharp.Tests
public void CanAmendACommitWithMoreThanOneParent()
{
string path = SandboxStandardTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
var mergedCommit = repo.Lookup<Commit>("be3563a");
Assert.NotNull(mergedCommit);
@@ -822,10 +830,10 @@ namespace LibGit2Sharp.Tests
AssertCommitHasBeenAmended(repo, amendedCommit, mergedCommit);
AssertRefLogEntry(repo, "HEAD",
- amendedCommit.Id,
string.Format("commit (amend): {0}", commitMessage),
mergedCommit.Id,
- amendedCommit.Committer);
+ amendedCommit.Id,
+ Constants.Identity, DateTimeOffset.Now);
}
}
diff --git a/LibGit2Sharp.Tests/PushFixture.cs b/LibGit2Sharp.Tests/PushFixture.cs
index 88e932ad..10261d0b 100644
--- a/LibGit2Sharp.Tests/PushFixture.cs
+++ b/LibGit2Sharp.Tests/PushFixture.cs
@@ -98,7 +98,7 @@ namespace LibGit2Sharp.Tests
// Create a new repository
string localRepoPath = InitNewRepository();
- using (var localRepo = new Repository(localRepoPath))
+ using (var localRepo = new Repository(localRepoPath, new RepositoryOptions { Identity = Constants.Identity }))
{
// Add a commit
Commit first = AddCommitToRepo(localRepo);
@@ -129,8 +129,9 @@ namespace LibGit2Sharp.Tests
AssertRemoteHeadTipEquals(localRepo, second.Sha);
AssertRefLogEntry(localRepo, "refs/remotes/origin/master",
- localRepo.Head.Tip.Id, "update by push",
- oldId);
+ "update by push",
+ oldId, localRepo.Head.Tip.Id,
+ Constants.Identity, DateTimeOffset.Now);
}
}
diff --git a/LibGit2Sharp.Tests/ReferenceFixture.cs b/LibGit2Sharp.Tests/ReferenceFixture.cs
index 4674ecef..07432632 100644
--- a/LibGit2Sharp.Tests/ReferenceFixture.cs
+++ b/LibGit2Sharp.Tests/ReferenceFixture.cs
@@ -22,7 +22,7 @@ namespace LibGit2Sharp.Tests
const string name = "refs/heads/unit_test";
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
@@ -35,8 +35,9 @@ namespace LibGit2Sharp.Tests
Assert.NotNull(repo.Refs[name]);
AssertRefLogEntry(repo, name,
- newRef.ResolveToDirectReference().Target.Id,
- "branch: Created from be3563ae3f795b2b4353bcce3a527ad0a4f7f644");
+ "branch: Created from be3563ae3f795b2b4353bcce3a527ad0a4f7f644",
+ null, newRef.ResolveToDirectReference().Target.Id, Constants.Identity, DateTimeOffset.Now
+ );
}
}
@@ -47,11 +48,11 @@ namespace LibGit2Sharp.Tests
const string logMessage = "Create new ref";
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
- var newRef = (DirectReference)repo.Refs.Add(name, "master^1^2", Constants.Signature, logMessage);
+ var newRef = (DirectReference)repo.Refs.Add(name, "master^1^2", logMessage);
Assert.NotNull(newRef);
Assert.Equal(name, newRef.CanonicalName);
Assert.NotNull(newRef.Target);
@@ -59,9 +60,9 @@ namespace LibGit2Sharp.Tests
Assert.Equal(newRef.Target.Sha, newRef.TargetIdentifier);
Assert.NotNull(repo.Refs[name]);
- AssertRefLogEntry(repo, name,
- newRef.ResolveToDirectReference().Target.Id,
- logMessage, committer: Constants.Signature);
+ AssertRefLogEntry(repo, name, logMessage,
+ null, newRef.ResolveToDirectReference().Target.Id,
+ Constants.Identity, DateTimeOffset.Now);
}
}
@@ -106,7 +107,7 @@ namespace LibGit2Sharp.Tests
var targetRef = repo.Refs[target];
- var newRef = repo.Refs.Add(name, targetRef, Constants.Signature, logMessage);
+ var newRef = repo.Refs.Add(name, targetRef, logMessage);
AssertSymbolicRef(newRef, repo, target, name);
Assert.Empty(repo.Refs.Log(newRef));
@@ -151,12 +152,12 @@ namespace LibGit2Sharp.Tests
const string logMessage = "Create new ref";
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
var oldRef = repo.Refs[name];
- var newRef = (DirectReference)repo.Refs.Add(name, target, Constants.Signature, logMessage, true);
+ var newRef = (DirectReference)repo.Refs.Add(name, target, logMessage, true);
Assert.NotNull(newRef);
Assert.Equal(name, newRef.CanonicalName);
Assert.NotNull(newRef.Target);
@@ -164,9 +165,9 @@ namespace LibGit2Sharp.Tests
Assert.Equal(target, ((DirectReference)repo.Refs[name]).Target.Sha);
AssertRefLogEntry(repo, name,
- newRef.ResolveToDirectReference().Target.Id,
logMessage, ((DirectReference)oldRef).Target.Id,
- Constants.Signature);
+ newRef.ResolveToDirectReference().Target.Id,
+ Constants.Identity, DateTimeOffset.Now);
}
}
@@ -178,22 +179,22 @@ namespace LibGit2Sharp.Tests
const string logMessage = "Create new ref";
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
var oldtarget = repo.Refs[name].ResolveToDirectReference().Target.Id;
- var newRef = (SymbolicReference)repo.Refs.Add(name, target, Constants.Signature, logMessage, true);
+ var newRef = (SymbolicReference)repo.Refs.Add(name, target, logMessage, true);
Assert.NotNull(newRef);
Assert.Equal(name, newRef.CanonicalName);
Assert.NotNull(newRef.Target);
Assert.Equal("a4a7dce85cf63874e984719f4fdd239f5145052f", newRef.ResolveToDirectReference().Target.Sha);
Assert.Equal(target, ((SymbolicReference)repo.Refs.Head).Target.CanonicalName);
- AssertRefLogEntry(repo, name,
+ AssertRefLogEntry(repo, name, logMessage,
+ oldtarget,
newRef.ResolveToDirectReference().Target.Id,
- logMessage, oldtarget,
- Constants.Signature);
+ Constants.Identity, DateTimeOffset.Now);
}
}
@@ -498,36 +499,35 @@ namespace LibGit2Sharp.Tests
public void CanUpdateHeadWithEitherAnObjectIdOrAReference()
{
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
Reference head = repo.Refs.Head;
Reference test = repo.Refs["refs/heads/test"];
- Reference direct = repo.Refs.UpdateTarget(head, new ObjectId(test.TargetIdentifier), Constants.Signature, null);
+ Reference direct = repo.Refs.UpdateTarget(head, new ObjectId(test.TargetIdentifier), null);
Assert.True((direct is DirectReference));
Assert.Equal(test.TargetIdentifier, direct.TargetIdentifier);
Assert.Equal(repo.Refs.Head, direct);
var testTargetId = test.ResolveToDirectReference().Target.Id;
- AssertRefLogEntry(repo, "HEAD",
- testTargetId,
- null,
+ AssertRefLogEntry(repo, "HEAD", null,
head.ResolveToDirectReference().Target.Id,
- Constants.Signature);
+ testTargetId,
+ Constants.Identity, DateTimeOffset.Now);
const string secondLogMessage = "second update target message";
- Reference symref = repo.Refs.UpdateTarget(head, test, Constants.Signature, secondLogMessage);
+ Reference symref = repo.Refs.UpdateTarget(head, test, secondLogMessage);
Assert.True((symref is SymbolicReference));
Assert.Equal(test.CanonicalName, symref.TargetIdentifier);
Assert.Equal(repo.Refs.Head, symref);
AssertRefLogEntry(repo, "HEAD",
- testTargetId,
secondLogMessage,
testTargetId,
- Constants.Signature);
+ testTargetId,
+ Constants.Identity, DateTimeOffset.Now);
}
}
@@ -535,7 +535,7 @@ namespace LibGit2Sharp.Tests
public void CanUpdateTargetOfADirectReferenceWithARevparseSpec()
{
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);
@@ -545,7 +545,7 @@ namespace LibGit2Sharp.Tests
var @from = master.Target.Id;
const string logMessage = "update target message";
- var newRef = (DirectReference)repo.Refs.UpdateTarget(master, "master^1^2", Constants.Signature, logMessage);
+ var newRef = (DirectReference)repo.Refs.UpdateTarget(master, "master^1^2", logMessage);
Assert.NotNull(newRef);
Assert.Equal(name, newRef.CanonicalName);
Assert.NotNull(newRef.Target);
@@ -554,10 +554,10 @@ namespace LibGit2Sharp.Tests
Assert.NotNull(repo.Refs[name]);
AssertRefLogEntry(repo, name,
- newRef.Target.Id,
logMessage,
@from,
- Constants.Signature);
+ newRef.Target.Id,
+ Constants.Identity, DateTimeOffset.Now);
}
}
@@ -648,7 +648,7 @@ namespace LibGit2Sharp.Tests
public void CanRenameAReferenceToADifferentReferenceHierarchy()
{
string path = SandboxBareTestRepo();
- using (var repo = new Repository(path))
+ using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
const string oldName = "refs/tags/test";
const string newName = "refs/atic/tagtest";
@@ -662,8 +662,11 @@ namespace LibGit2Sharp.Tests
Assert.Equal(newName, renamed.CanonicalName);
Assert.Equal(oldId, renamed.ResolveToDirectReference().Target.Id);
- AssertRefLogEntry(repo, newName, renamed.ResolveToDirectReference().Target.Id,
- string.Format("reference: renamed {0} to {1}", oldName, newName));
+ AssertRefLogEntry(repo, newName,
+ string.Format("reference: renamed {0} to {1}", oldName, newName),
+ oldId,
+ renamed.ResolveToDirectReference().Target.Id,
+ Constants.Identity, DateTimeOffset.Now);
}
}
diff --git a/LibGit2Sharp.Tests/ReflogFixture.cs b/LibGit2Sharp.Tests/ReflogFixture.cs
index cda56e9c..88785d67 100644
--- a/LibGit2Sharp.Tests/ReflogFixture.cs
+++ b/LibGit2Sharp.Tests/ReflogFixture.cs
@@ -1,4 +1,5 @@
-using System.IO;
+using System;
+using System.IO;
using System.Linq;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
@@ -56,7 +57,9 @@ namespace LibGit2Sharp.Tests
{
string repoPath = InitNewRepository();
- using (var repo = new Repository(repoPath))
+ var identity = Constants.Identity;
+
+ using (var repo = new Repository(repoPath, new RepositoryOptions{ Identity = identity }))
{
// setup refs as HEAD => unit_test => master
var newRef = repo.Refs.Add("refs/heads/unit_test", "refs/heads/master");
@@ -74,14 +77,26 @@ namespace LibGit2Sharp.Tests
// Assert a reflog entry is created on HEAD
Assert.Equal(1, repo.Refs.Log("HEAD").Count());
var reflogEntry = repo.Refs.Log("HEAD").First();
- Assert.Equal(author, reflogEntry.Committer);
+
+ Assert.Equal(identity.Name, reflogEntry.Committer.Name);
+ Assert.Equal(identity.Email, reflogEntry.Committer.Email);
+
+ var now = DateTimeOffset.Now;
+ Assert.InRange(reflogEntry.Committer.When, now - TimeSpan.FromSeconds(1), now);
+
Assert.Equal(commit.Id, reflogEntry.To);
Assert.Equal(ObjectId.Zero, reflogEntry.From);
// Assert the same reflog entry is created on refs/heads/master
Assert.Equal(1, repo.Refs.Log("refs/heads/master").Count());
reflogEntry = repo.Refs.Log("HEAD").First();
- Assert.Equal(author, reflogEntry.Committer);
+
+ Assert.Equal(identity.Name, reflogEntry.Committer.Name);
+ Assert.Equal(identity.Email, reflogEntry.Committer.Email);
+
+ now = DateTimeOffset.Now;
+ Assert.InRange(reflogEntry.Committer.When, now - TimeSpan.FromSeconds(1), now);
+
Assert.Equal(commit.Id, reflogEntry.To);
Assert.Equal(ObjectId.Zero, reflogEntry.From);
@@ -116,7 +131,9 @@ namespace LibGit2Sharp.Tests
{
string repoPath = SandboxStandardTestRepo();
- using (var repo = new Repository(repoPath))
+ var identity = Constants.Identity;
+
+ using (var repo = new Repository(repoPath, new RepositoryOptions { Identity = identity }))
{
Assert.False(repo.Info.IsHeadDetached);
@@ -134,7 +151,13 @@ namespace LibGit2Sharp.Tests
// Assert a reflog entry is created on HEAD
var reflogEntry = repo.Refs.Log("HEAD").First();
- Assert.Equal(author, reflogEntry.Committer);
+
+ Assert.Equal(identity.Name, reflogEntry.Committer.Name);
+ Assert.Equal(identity.Email, reflogEntry.Committer.Email);
+
+ var now = DateTimeOffset.Now;
+ Assert.InRange(reflogEntry.Committer.When, now - TimeSpan.FromSeconds(1), now);
+
Assert.Equal(commit.Id, reflogEntry.To);
Assert.Equal(string.Format("commit: {0}", commitMessage), repo.Refs.Log("HEAD").First().Message);
}
@@ -174,7 +197,7 @@ namespace LibGit2Sharp.Tests
public void UnsignedMethodsWriteCorrectlyToTheReflog()
{
var repoPath = InitNewRepository(true);
- using (var repo = new Repository(repoPath))
+ using (var repo = new Repository(repoPath, new RepositoryOptions{ Identity = Constants.Identity }))
{
EnableRefLog(repo);
@@ -184,7 +207,7 @@ namespace LibGit2Sharp.Tests
tree, Enumerable.Empty<Commit>(), false);
var direct = repo.Refs.Add("refs/heads/direct", commit.Id);
- AssertRefLogEntry(repo, direct.CanonicalName, direct.ResolveToDirectReference().Target.Id, null);
+ AssertRefLogEntry(repo, direct.CanonicalName, null, null, direct.ResolveToDirectReference().Target.Id, Constants.Identity, DateTimeOffset.Now);
var symbolic = repo.Refs.Add("refs/heads/symbolic", direct);
Assert.Empty(repo.Refs.Log(symbolic)); // creation of symbolic refs doesn't update the reflog
diff --git a/LibGit2Sharp.Tests/ResetHeadFixture.cs b/LibGit2Sharp.Tests/ResetHeadFixture.cs
index b1cfda8d..a6132ec1 100644
--- a/LibGit2Sharp.Tests/ResetHeadFixture.cs
+++ b/LibGit2Sharp.Tests/ResetHeadFixture.cs
@@ -94,7 +94,7 @@ namespace LibGit2Sharp.Tests
{
string repoPath = InitNewRepository();
- using (var repo = new Repository(repoPath))
+ using (var repo = new Repository(repoPath, new RepositoryOptions{ Identity = Constants.Identity }))
{
FeedTheRepository(repo);
@@ -118,38 +118,40 @@ namespace LibGit2Sharp.Tests
Assert.Equal(FileStatus.Staged, repo.RetrieveStatus("a.txt"));
AssertRefLogEntry(repo, "HEAD",
- tag.Target.Id,
string.Format("reset: moving to {0}", tag.Target.Sha),
- oldHeadId);
+ oldHeadId,
+ tag.Target.Id,
+ Constants.Identity, DateTimeOffset.Now);
if (!shouldHeadBeDetached)
{
AssertRefLogEntry(repo, branch.CanonicalName,
- tag.Target.Id,
string.Format("reset: moving to {0}", tag.Target.Sha),
- oldHeadId);
+ oldHeadId,
+ tag.Target.Id,
+ Constants.Identity, DateTimeOffset.Now);
}
/* Reset --soft the Head to a commit through its sha */
- repo.Reset(ResetMode.Soft, branch.Tip.Sha, Constants.Signature, "FOO");
+ repo.Reset(ResetMode.Soft, branch.Tip.Sha);
Assert.Equal(expectedHeadName, repo.Head.Name);
Assert.Equal(branch.Tip.Sha, repo.Head.Tip.Sha);
Assert.Equal(FileStatus.Unaltered, repo.RetrieveStatus("a.txt"));
AssertRefLogEntry(repo, "HEAD",
- branch.Tip.Id,
- "FOO",
+ string.Format("reset: moving to {0}", branch.Tip.Sha),
tag.Target.Id,
- Constants.Signature);
+ branch.Tip.Id,
+ Constants.Identity, DateTimeOffset.Now);
if (!shouldHeadBeDetached)
{
AssertRefLogEntry(repo, branch.CanonicalName,
- branch.Tip.Id,
- "FOO",
+ string.Format("reset: moving to {0}", branch.Tip.Sha),
tag.Target.Id,
- Constants.Signature);
+ branch.Tip.Id,
+ Constants.Identity, DateTimeOffset.Now);
}
}
}
@@ -178,7 +180,7 @@ namespace LibGit2Sharp.Tests
{
string repoPath = InitNewRepository();
- using (var repo = new Repository(repoPath))
+ using (var repo = new Repository(repoPath, new RepositoryOptions { Identity = Constants.Identity }))
{
FeedTheRepository(repo);
@@ -191,14 +193,16 @@ namespace LibGit2Sharp.Tests
Assert.Equal(FileStatus.Modified, repo.RetrieveStatus("a.txt"));
AssertRefLogEntry(repo, "HEAD",
- tag.Target.Id,
string.Format("reset: moving to {0}", tag.Target.Sha),
- oldHeadId);
+ oldHeadId,
+ tag.Target.Id,
+ Constants.Identity, DateTimeOffset.Now);
AssertRefLogEntry(repo, "refs/heads/mybranch",
- tag.Target.Id,
string.Format("reset: moving to {0}", tag.Target.Sha),
- oldHeadId);
+ oldHeadId,
+ tag.Target.Id,
+ Constants.Identity, DateTimeOffset.Now);
}
}
diff --git a/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs b/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
index 63398fc4..a7cc1a58 100644
--- a/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
+++ b/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
@@ -405,8 +405,8 @@ namespace LibGit2Sharp.Tests.TestHelpers
}
protected static void AssertRefLogEntry(IRepository repo, string canonicalName,
- ObjectId to, string message, ObjectId @from = null,
- Signature committer = null)
+ string message, ObjectId @from, ObjectId to,
+ Identity committer, DateTimeOffset when)
{
var reflogEntry = repo.Refs.Log(canonicalName).First();
@@ -414,9 +414,8 @@ namespace LibGit2Sharp.Tests.TestHelpers
Assert.Equal(message, reflogEntry.Message);
Assert.Equal(@from ?? ObjectId.Zero, reflogEntry.From);
- committer = committer ?? repo.Config.BuildSignature(DateTimeOffset.Now);
Assert.Equal(committer.Email, reflogEntry.Committer.Email);
- Assert.InRange(reflogEntry.Committer.When, committer.When - TimeSpan.FromSeconds(5), committer.When);
+ Assert.InRange(reflogEntry.Committer.When, when - TimeSpan.FromSeconds(5), when);
}
protected static void EnableRefLog(IRepository repository, bool enable = true)