diff options
author | nulltoken <emeric.fermas@gmail.com> | 2014-08-25 12:32:04 +0400 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2014-08-27 21:38:47 +0400 |
commit | 4252d5539b384f6df36a42be7a115030aa269b2c (patch) | |
tree | 71807665d42112eaf91e24430d0dac9edeb6d2e8 /LibGit2Sharp.Tests | |
parent | b5c658d3eca47f8fa26626cb08d7067181e2d4e6 (diff) |
Ensure Tags can be created in detached Head state
Fix #791
Diffstat (limited to 'LibGit2Sharp.Tests')
-rw-r--r-- | LibGit2Sharp.Tests/ResetHeadFixture.cs | 2 | ||||
-rw-r--r-- | LibGit2Sharp.Tests/ResetIndexFixture.cs | 2 | ||||
-rw-r--r-- | LibGit2Sharp.Tests/TagFixture.cs | 25 |
3 files changed, 25 insertions, 4 deletions
diff --git a/LibGit2Sharp.Tests/ResetHeadFixture.cs b/LibGit2Sharp.Tests/ResetHeadFixture.cs index 82fe2c53..870e46c3 100644 --- a/LibGit2Sharp.Tests/ResetHeadFixture.cs +++ b/LibGit2Sharp.Tests/ResetHeadFixture.cs @@ -18,7 +18,7 @@ namespace LibGit2Sharp.Tests using (var repo = new Repository(repoPath)) { - Assert.Throws<LibGit2SharpException>(() => repo.Reset(ResetMode.Soft)); + Assert.Throws<UnbornBranchException>(() => repo.Reset(ResetMode.Soft)); } } diff --git a/LibGit2Sharp.Tests/ResetIndexFixture.cs b/LibGit2Sharp.Tests/ResetIndexFixture.cs index 0e774cd7..9cc7849a 100644 --- a/LibGit2Sharp.Tests/ResetIndexFixture.cs +++ b/LibGit2Sharp.Tests/ResetIndexFixture.cs @@ -25,7 +25,7 @@ namespace LibGit2Sharp.Tests using (var repo = new Repository(repoPath)) { - Assert.Throws<LibGit2SharpException>(() => repo.Reset()); + Assert.Throws<UnbornBranchException>(() => repo.Reset()); } } diff --git a/LibGit2Sharp.Tests/TagFixture.cs b/LibGit2Sharp.Tests/TagFixture.cs index 97f5b24d..6426ccb1 100644 --- a/LibGit2Sharp.Tests/TagFixture.cs +++ b/LibGit2Sharp.Tests/TagFixture.cs @@ -234,7 +234,7 @@ namespace LibGit2Sharp.Tests using (var repo = new Repository(repoPath)) { - Assert.Throws<LibGit2SharpException>(() => repo.ApplyTag("mynotag")); + Assert.Throws<UnbornBranchException>(() => repo.ApplyTag("mynotag")); } } @@ -246,7 +246,8 @@ namespace LibGit2Sharp.Tests using (var repo = new Repository(repoPath)) { - Assert.Throws<LibGit2SharpException>(() => repo.ApplyTag("mytaghead", "HEAD")); + Assert.Throws<UnbornBranchException>(() => repo.ApplyTag("mytaghead", "HEAD")); + Assert.Throws<UnbornBranchException>(() => repo.ApplyTag("mytaghead")); } } @@ -288,6 +289,26 @@ namespace LibGit2Sharp.Tests } [Fact] + public void CanAddATagForImplicitHeadInDetachedState() + { + string path = CloneStandardTestRepo(); + using (var repo = new Repository(path)) + { + repo.Checkout(repo.Head.Tip); + + Assert.True(repo.Info.IsHeadDetached); + + Tag tag = repo.ApplyTag("mytag"); + Assert.NotNull(tag); + + Assert.Equal(repo.Head.Tip.Id, tag.Target.Id); + + Tag retrievedTag = repo.Tags[tag.CanonicalName]; + Assert.Equal(retrievedTag, tag); + } + } + + [Fact] // Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L87) public void CreatingADuplicateTagThrows() { |