|
1 | 1 | using System;
|
2 | 2 | using System.IO;
|
| 3 | +using System.Linq; |
3 | 4 | using System.Text;
|
4 | 5 | using LibGit2Sharp.Tests.TestHelpers;
|
5 | 6 | using Xunit;
|
@@ -174,5 +175,38 @@ public void CanProvideDifferentConfigurationFilesToARepository()
|
174 | 175 |
|
175 | 176 | AssertValueInConfigFile(systemLocation, "xpaulbettsx");
|
176 | 177 | }
|
| 178 | + |
| 179 | + [Fact] |
| 180 | + public void CanCommitOnBareRepository() |
| 181 | + { |
| 182 | + string repoPath = InitNewRepository(true); |
| 183 | + SelfCleaningDirectory scd = BuildSelfCleaningDirectory(); |
| 184 | + string workPath = Path.Combine(scd.RootedDirectoryPath, "work"); |
| 185 | + Directory.CreateDirectory(workPath); |
| 186 | + |
| 187 | + var repositoryOptions = new RepositoryOptions |
| 188 | + { |
| 189 | + WorkingDirectoryPath = workPath, |
| 190 | + IndexPath = Path.Combine(scd.RootedDirectoryPath, "index") |
| 191 | + }; |
| 192 | + |
| 193 | + using (var repo = new Repository(repoPath, repositoryOptions)) |
| 194 | + { |
| 195 | + const string relativeFilepath = "test.txt"; |
| 196 | + Touch(repo.Info.WorkingDirectory, relativeFilepath, "test\n"); |
| 197 | + repo.Index.Stage(relativeFilepath); |
| 198 | + |
| 199 | + Assert.NotNull(repo.Commit("Initial commit", Constants.Signature, Constants.Signature)); |
| 200 | + Assert.Equal(1, repo.Head.Commits.Count()); |
| 201 | + Assert.Equal(1, repo.Commits.Count()); |
| 202 | + |
| 203 | + // However, as we're in a bare repository, by default core.logallrefupdates is unset |
| 204 | + Assert.Null(repo.Config.Get<bool>("core.logallrefupdates")); |
| 205 | + |
| 206 | + // TODO: Uncomment these lines once this is handled at the libgit2 level |
| 207 | + //Assert.Equal(0, repo.Refs.Log("refs/heads/master").Count()); |
| 208 | + //Assert.Equal(0, repo.Refs.Log("HEAD").Count()); |
| 209 | + } |
| 210 | + } |
177 | 211 | }
|
178 | 212 | }
|
0 commit comments