Skip to content

Commit

Permalink
Add support for git worktrees in tests (#3434)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReubenBond authored Apr 5, 2024
1 parent 114c0ba commit 5d631c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion tests/Aspire.Hosting.Tests/MSBuildTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ private static string GetRepoRoot()
{
string directory = AppContext.BaseDirectory;

while (directory != null && !Directory.Exists(Path.Combine(directory, ".git")))
// To support git worktrees, check for either a directory or a file named ".git"
while (directory != null && !Directory.Exists(Path.Combine(directory, ".git")) && !File.Exists(Path.Combine(directory, ".git")))
{
directory = Directory.GetParent(directory)!.FullName;
}
Expand Down
3 changes: 2 additions & 1 deletion tests/Shared/WorkloadTesting/BuildEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public BuildEnvironment(bool expectSdkWithWorkload = true, Action<string, string
DirectoryInfo? solutionRoot = new(AppContext.BaseDirectory);
while (solutionRoot != null)
{
if (Directory.Exists(Path.Combine(solutionRoot.FullName, ".git")))
// To support git worktrees, check for either a directory or a file named ".git"
if (Directory.Exists(Path.Combine(solutionRoot.FullName, ".git")) || File.Exists(Path.Combine(solutionRoot.FullName, ".git")))
{
break;
}
Expand Down

0 comments on commit 5d631c6

Please sign in to comment.