From 0c290c4c8ae716d9309c201446b92abba79c9209 Mon Sep 17 00:00:00 2001 From: Metalrom Date: Fri, 14 Dec 2012 11:45:40 +0100 Subject: Adds Reset(ResetOptions resetOptions, Commit commit) method in Repository --- LibGit2Sharp.Tests/ResetHeadFixture.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'LibGit2Sharp.Tests/ResetHeadFixture.cs') diff --git a/LibGit2Sharp.Tests/ResetHeadFixture.cs b/LibGit2Sharp.Tests/ResetHeadFixture.cs index a6d94aaf..d757633c 100644 --- a/LibGit2Sharp.Tests/ResetHeadFixture.cs +++ b/LibGit2Sharp.Tests/ResetHeadFixture.cs @@ -35,6 +35,21 @@ namespace LibGit2Sharp.Tests } } + [Fact] + public void SoftResetToAParentCommitChangesTheTargetOfTheHead() + { + TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(); + + using (var repo = new Repository(path.RepositoryPath)) + { + var headCommit = repo.Head.Tip; + var firstCommitParent = headCommit.Parents.First(); + repo.Reset(ResetOptions.Soft, firstCommitParent); + + Assert.Equal(firstCommitParent, repo.Head.Tip); + } + } + [Fact] public void SoftResetSetsTheHeadToTheDereferencedCommitOfAChainedTag() { @@ -53,7 +68,8 @@ namespace LibGit2Sharp.Tests { using (var repo = new Repository(BareTestRepoPath)) { - Assert.Throws(() => repo.Reset(ResetOptions.Soft, null)); + Assert.Throws(() => repo.Reset(ResetOptions.Soft, (string)null)); + Assert.Throws(() => repo.Reset(ResetOptions.Soft, (Commit)null)); Assert.Throws(() => repo.Reset(ResetOptions.Soft, "")); Assert.Throws(() => repo.Reset(ResetOptions.Soft, Constants.UnknownSha)); Assert.Throws(() => repo.Reset(ResetOptions.Soft, repo.Head.Tip.Tree.Sha)); -- cgit v1.2.3