Skip to content

Commit 4d30873

Browse files
chusemanermshiperete
authored andcommitted
Add cache key creation test for a worktree
1 parent eb7dfed commit 4d30873

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/GitVersionCore.Tests/ExecuteCoreTests.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,35 @@ public void CacheKeySameAfterReNormalizing()
4141
});
4242
}
4343

44+
[Test]
45+
[Category("NoMono")]
46+
[Description("LibGit2Sharp fails here when running under Mono")]
47+
public void CacheKeyForWorktree()
48+
{
49+
var versionAndBranchFinder = new ExecuteCore(fileSystem);
50+
51+
RepositoryScope(versionAndBranchFinder, (fixture, vv) =>
52+
{
53+
var worktreePath = Path.Combine(Directory.GetParent(fixture.RepositoryPath).FullName, Guid.NewGuid().ToString());
54+
try
55+
{
56+
// create a branch and a new worktree for it
57+
var repo = new Repository(fixture.RepositoryPath);
58+
repo.Worktrees.Add("worktree", worktreePath, false);
59+
60+
var targetUrl = "https://github.com/GitTools/GitVersion.git";
61+
var gitPreparer = new GitPreparer(targetUrl, null, new Authentication(), false, worktreePath);
62+
var configFileLocator = new DefaultConfigFileLocator();
63+
var cacheKey = GitVersionCacheKeyFactory.Create(fileSystem, gitPreparer, null, configFileLocator);
64+
cacheKey.Value.ShouldNotBeEmpty();
65+
}
66+
finally
67+
{
68+
DirectoryHelper.DeleteDirectory(worktreePath);
69+
}
70+
});
71+
}
72+
4473
[Test]
4574
public void CacheFileExistsOnDisk()
4675
{

0 commit comments

Comments
 (0)