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:
authordavidebbo <david.ebbo@microsoft.com>2011-06-05 21:11:24 +0400
committernulltoken <emeric.fermas@gmail.com>2011-06-05 21:28:09 +0400
commit69935b56b3da99a7c5fe1dc9bc403e5079b08444 (patch)
tree601b1eb8b1737517cd6bf5b82a39fa40ad1f79dd
parentfaa21e034d05759281ec9c90a10a8d6ca27c37e0 (diff)
Fix test repo copying when repo is not bare
-rw-r--r--LibGit2Sharp.Tests/Constants.cs3
-rw-r--r--LibGit2Sharp.Tests/IndexFixture.cs6
-rw-r--r--LibGit2Sharp.Tests/TestHelpers/TemporaryCloneOfTestRepo.cs22
3 files changed, 24 insertions, 7 deletions
diff --git a/LibGit2Sharp.Tests/Constants.cs b/LibGit2Sharp.Tests/Constants.cs
index 757b1a66..c49e38b4 100644
--- a/LibGit2Sharp.Tests/Constants.cs
+++ b/LibGit2Sharp.Tests/Constants.cs
@@ -3,7 +3,8 @@
public static class Constants
{
public const string TestRepoPath = "./Resources/testrepo.git";
- public const string TestRepoWithWorkingDirPath = "./Resources/testrepo_wd/.git";
+ public const string TestRepoWithWorkingDirRootPath = "./Resources/testrepo_wd";
+ public const string TestRepoWithWorkingDirPath = TestRepoWithWorkingDirRootPath + "/.git";
public const string TemporaryReposPath = "TestRepos";
public const string UnknownSha = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
}
diff --git a/LibGit2Sharp.Tests/IndexFixture.cs b/LibGit2Sharp.Tests/IndexFixture.cs
index 8b6494ca..abaf931c 100644
--- a/LibGit2Sharp.Tests/IndexFixture.cs
+++ b/LibGit2Sharp.Tests/IndexFixture.cs
@@ -104,7 +104,7 @@ namespace LibGit2Sharp.Tests
[Test]
public void CanStageANewFile()
{
- using (var path = new TemporaryCloneOfTestRepo(Constants.TestRepoWithWorkingDirPath))
+ using (var path = new TemporaryCloneOfTestRepo(Constants.TestRepoWithWorkingDirRootPath))
using (var repo = new Repository(path.RepositoryPath))
{
var count = repo.Index.Count;
@@ -143,7 +143,7 @@ namespace LibGit2Sharp.Tests
[Test]
public void CanStageANewFileWithAFullPath()
{
- using (var path = new TemporaryCloneOfTestRepo(Constants.TestRepoWithWorkingDirPath))
+ using (var path = new TemporaryCloneOfTestRepo(Constants.TestRepoWithWorkingDirRootPath))
using (var repo = new Repository(path.RepositoryPath))
{
var count = repo.Index.Count;
@@ -162,7 +162,7 @@ namespace LibGit2Sharp.Tests
public void StagingANewFileWithAFullPathWhichEscapesOutOfTheWorkingDirThrows()
{
using (var scd = new SelfCleaningDirectory())
- using (var path = new TemporaryCloneOfTestRepo(Constants.TestRepoWithWorkingDirPath))
+ using (var path = new TemporaryCloneOfTestRepo(Constants.TestRepoWithWorkingDirRootPath))
using (var repo = new Repository(path.RepositoryPath))
{
var di = Directory.CreateDirectory(scd.DirectoryPath);
diff --git a/LibGit2Sharp.Tests/TestHelpers/TemporaryCloneOfTestRepo.cs b/LibGit2Sharp.Tests/TestHelpers/TemporaryCloneOfTestRepo.cs
index 9725b7e6..1c411b92 100644
--- a/LibGit2Sharp.Tests/TestHelpers/TemporaryCloneOfTestRepo.cs
+++ b/LibGit2Sharp.Tests/TestHelpers/TemporaryCloneOfTestRepo.cs
@@ -7,10 +7,26 @@ namespace LibGit2Sharp.Tests.TestHelpers
public TemporaryCloneOfTestRepo(string sourceDirectoryPath = Constants.TestRepoPath)
{
var source = new DirectoryInfo(sourceDirectoryPath);
- var tempRepository = new DirectoryInfo(Path.Combine(DirectoryPath, source.Name));
- RepositoryPath = tempRepository.FullName;
- DirectoryHelper.CopyFilesRecursively(source, tempRepository);
+ if (Directory.Exists(Path.Combine(sourceDirectoryPath, ".git")))
+ {
+ // If there is a .git subfolder, we're dealing with a non-bare repo and we have to
+ // copy the working folder as well
+
+ RepositoryPath = Path.Combine(DirectoryPath, ".git");
+
+ DirectoryHelper.CopyFilesRecursively(source, new DirectoryInfo(DirectoryPath));
+ }
+ else
+ {
+ // It's a bare repo
+
+ var tempRepository = new DirectoryInfo(Path.Combine(DirectoryPath, source.Name));
+
+ RepositoryPath = tempRepository.FullName;
+
+ DirectoryHelper.CopyFilesRecursively(source, tempRepository);
+ }
}
public string RepositoryPath { get; private set; }