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:
authorKeith Dahlby <dahlbyk@gmail.com>2013-08-27 08:32:43 +0400
committerKeith Dahlby <dahlbyk@gmail.com>2013-08-30 17:42:05 +0400
commitddec9f033b38072a41f3d745026be0d0dddb3fbf (patch)
treeafd95079b1be01b68e4d9352f572570bfa062a90 /LibGit2Sharp.Tests/BranchFixture.cs
parent625ebbd4bcdd8ab45e89241326ccfcbcfd9a8b7b (diff)
Append to reflog in Branches.Add() and Move()
Diffstat (limited to 'LibGit2Sharp.Tests/BranchFixture.cs')
-rw-r--r--LibGit2Sharp.Tests/BranchFixture.cs97
1 files changed, 81 insertions, 16 deletions
diff --git a/LibGit2Sharp.Tests/BranchFixture.cs b/LibGit2Sharp.Tests/BranchFixture.cs
index bb5d6b5e..493dff72 100644
--- a/LibGit2Sharp.Tests/BranchFixture.cs
+++ b/LibGit2Sharp.Tests/BranchFixture.cs
@@ -20,15 +20,23 @@ namespace LibGit2Sharp.Tests
string path = CloneBareTestRepo();
using (var repo = new Repository(path))
{
- Branch newBranch = repo.CreateBranch(name, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644");
+ const string committish = "be3563ae3f795b2b4353bcce3a527ad0a4f7f644";
+
+ Branch newBranch = repo.CreateBranch(name, committish);
Assert.NotNull(newBranch);
Assert.Equal(name, newBranch.Name);
Assert.Equal("refs/heads/" + name, newBranch.CanonicalName);
Assert.NotNull(newBranch.Tip);
- Assert.Equal("be3563ae3f795b2b4353bcce3a527ad0a4f7f644", newBranch.Tip.Sha);
+ Assert.Equal(committish, newBranch.Tip.Sha);
Assert.NotNull(repo.Branches.SingleOrDefault(p => p.Name == name));
+ AssertRefLogEntry(repo, newBranch.CanonicalName,
+ newBranch.Tip.Id,
+ "branch: Created from " + committish,
+ committer: newBranch.Tip.Committer);
+
repo.Branches.Remove(newBranch.Name);
+ Assert.Null(repo.Branches[name]);
}
}
@@ -39,18 +47,29 @@ namespace LibGit2Sharp.Tests
using (var repo = new Repository(path))
{
const string name = "unit_test";
- Branch newBranch = repo.CreateBranch(name, "be3563a");
+ const string committish = "be3563a";
+
+ Branch newBranch = repo.CreateBranch(name, committish);
Assert.Equal("refs/heads/" + name, newBranch.CanonicalName);
Assert.Equal("be3563ae3f795b2b4353bcce3a527ad0a4f7f644", newBranch.Tip.Sha);
+
+ AssertRefLogEntry(repo, newBranch.CanonicalName,
+ newBranch.Tip.Id,
+ "branch: Created from " + committish,
+ committer: newBranch.Tip.Committer);
}
}
- [Fact]
- public void CanCreateBranchFromImplicitHead()
+ [Theory]
+ [InlineData("32eab9cb1f450b5fe7ab663462b77d7f4b703344")]
+ [InlineData("master")]
+ public void CanCreateBranchFromImplicitHead(string headCommitOrBranchSpec)
{
- string path = CloneBareTestRepo();
+ string path = CloneStandardTestRepo();
using (var repo = new Repository(path))
{
+ repo.Checkout(headCommitOrBranchSpec);
+
const string name = "unit_test";
Branch newBranch = repo.CreateBranch(name);
Assert.NotNull(newBranch);
@@ -58,21 +77,35 @@ namespace LibGit2Sharp.Tests
Assert.Equal("refs/heads/" + name, newBranch.CanonicalName);
Assert.False(newBranch.IsCurrentRepositoryHead);
Assert.NotNull(newBranch.Tip);
- Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", newBranch.Tip.Sha);
+ Assert.Equal("32eab9cb1f450b5fe7ab663462b77d7f4b703344", newBranch.Tip.Sha);
Assert.NotNull(repo.Branches.SingleOrDefault(p => p.Name == name));
+
+ AssertRefLogEntry(repo, newBranch.CanonicalName,
+ newBranch.Tip.Id,
+ "branch: Created from " + headCommitOrBranchSpec,
+ committer: newBranch.Tip.Committer);
}
}
- [Fact]
- public void CanCreateBranchFromExplicitHead()
+ [Theory]
+ [InlineData("32eab9cb1f450b5fe7ab663462b77d7f4b703344")]
+ [InlineData("master")]
+ public void CanCreateBranchFromExplicitHead(string headCommitOrBranchSpec)
{
- string path = CloneBareTestRepo();
+ string path = CloneStandardTestRepo();
using (var repo = new Repository(path))
{
+ repo.Checkout(headCommitOrBranchSpec);
+
const string name = "unit_test";
Branch newBranch = repo.CreateBranch(name, "HEAD");
Assert.NotNull(newBranch);
- Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", newBranch.Tip.Sha);
+ Assert.Equal("32eab9cb1f450b5fe7ab663462b77d7f4b703344", newBranch.Tip.Sha);
+
+ AssertRefLogEntry(repo, newBranch.CanonicalName,
+ newBranch.Tip.Id,
+ "branch: Created from " + headCommitOrBranchSpec,
+ committer: newBranch.Tip.Committer);
}
}
@@ -87,6 +120,11 @@ namespace LibGit2Sharp.Tests
Branch newBranch = repo.CreateBranch(name, commit);
Assert.NotNull(newBranch);
Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", newBranch.Tip.Sha);
+
+ AssertRefLogEntry(repo, newBranch.CanonicalName,
+ newBranch.Tip.Id,
+ "branch: Created from " + newBranch.Tip.Sha,
+ committer: newBranch.Tip.Committer);
}
}
@@ -97,23 +135,37 @@ namespace LibGit2Sharp.Tests
using (var repo = new Repository(path))
{
const string name = "revparse_branch";
- var target = repo.Lookup<Commit>("master~2");
- Branch newBranch = repo.CreateBranch(name, target);
+ const string committish = "master~2";
+
+ Branch newBranch = repo.CreateBranch(name, committish);
Assert.NotNull(newBranch);
Assert.Equal("9fd738e8f7967c078dceed8190330fc8648ee56a", newBranch.Tip.Sha);
+
+ AssertRefLogEntry(repo, newBranch.CanonicalName,
+ newBranch.Tip.Id,
+ "branch: Created from " + committish,
+ committer: newBranch.Tip.Committer);
}
}
- [Fact]
- public void CreatingABranchFromATagPeelsToTheCommit()
+ [Theory]
+ [InlineData("test")]
+ [InlineData("refs/tags/test")]
+ public void CreatingABranchFromATagPeelsToTheCommit(string committish)
{
string path = CloneBareTestRepo();
using (var repo = new Repository(path))
{
const string name = "i-peel-tag";
- Branch newBranch = repo.CreateBranch(name, "refs/tags/test");
+
+ Branch newBranch = repo.CreateBranch(name, committish);
Assert.NotNull(newBranch);
Assert.Equal("e90810b8df3e80c413d903f631643c716887138d", newBranch.Tip.Sha);
+
+ AssertRefLogEntry(repo, newBranch.CanonicalName,
+ newBranch.Tip.Id,
+ "branch: Created from " + committish,
+ committer: newBranch.Tip.Committer);
}
}
@@ -726,12 +778,20 @@ namespace LibGit2Sharp.Tests
using (var repo = new Repository(path))
{
Assert.Null(repo.Branches["br3"]);
+ var br2 = repo.Branches["br2"];
+ Assert.NotNull(br2);
Branch newBranch = repo.Branches.Move("br2", "br3");
+
Assert.Equal("br3", newBranch.Name);
Assert.Null(repo.Branches["br2"]);
Assert.NotNull(repo.Branches["br3"]);
+
+ AssertRefLogEntry(repo, newBranch.CanonicalName,
+ newBranch.Tip.Id,
+ string.Format("Branch: renamed {0} to {1}", br2.CanonicalName, newBranch.CanonicalName),
+ committer: newBranch.Tip.Committer);
}
}
@@ -766,6 +826,11 @@ namespace LibGit2Sharp.Tests
Assert.Equal(newBranch, newTest);
Assert.Equal(br2.Tip, newTest.Tip);
+
+ AssertRefLogEntry(repo, newBranch.CanonicalName,
+ newBranch.Tip.Id,
+ string.Format("Branch: renamed {0} to {1}", br2.CanonicalName, newBranch.CanonicalName),
+ committer: newBranch.Tip.Committer);
}
}