diff options
author | mumitroller <mumitroller@tut.by> | 2014-04-26 15:53:55 +0400 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2014-04-26 20:34:41 +0400 |
commit | d8ac9e42e45f3e28daca1b04b389fc92fb89b410 (patch) | |
tree | 061452f5cca1c149c56db73204e72504ff3b2902 /LibGit2Sharp.Tests | |
parent | 5a00322dff71e380c1deb54a7fbbed3bfb348abb (diff) |
Fix Commit() so that it always updates the HEAD
Fix #692
Diffstat (limited to 'LibGit2Sharp.Tests')
-rw-r--r-- | LibGit2Sharp.Tests/RepositoryOptionsFixture.cs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/LibGit2Sharp.Tests/RepositoryOptionsFixture.cs b/LibGit2Sharp.Tests/RepositoryOptionsFixture.cs index 0a816bc7..946d4a31 100644 --- a/LibGit2Sharp.Tests/RepositoryOptionsFixture.cs +++ b/LibGit2Sharp.Tests/RepositoryOptionsFixture.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Linq; using System.Text; using LibGit2Sharp.Tests.TestHelpers; using Xunit; @@ -174,5 +175,31 @@ namespace LibGit2Sharp.Tests AssertValueInConfigFile(systemLocation, "xpaulbettsx"); } + + [Fact] + public void CanCommitOnBareRepository() + { + string repoPath = InitNewRepository(true); + SelfCleaningDirectory scd = BuildSelfCleaningDirectory(); + string workPath = Path.Combine(scd.RootedDirectoryPath, "work"); + Directory.CreateDirectory(workPath); + + var repositoryOptions = new RepositoryOptions + { + WorkingDirectoryPath = workPath, + IndexPath = Path.Combine(scd.RootedDirectoryPath, "index") + }; + + using (var repo = new Repository(repoPath, repositoryOptions)) + { + const string relativeFilepath = "test.txt"; + Touch(repo.Info.WorkingDirectory, relativeFilepath, "test\n"); + repo.Index.Stage(relativeFilepath); + + Assert.NotNull(repo.Commit("Initial commit", Constants.Signature, Constants.Signature)); + Assert.Equal(1, repo.Head.Commits.Count()); + Assert.Equal(1, repo.Commits.Count()); + } + } } } |