in src/TestHelpers/Embedded/BaselineHelper.cs [49:73]
public static string? TryGetAbsolutePathRelativeToRepoRoot(string path)
=> RepoRoot is not null ? CombinePaths(RepoRoot, path) : null;
public static string CombinePaths(params string[] paths)
=> Path.Combine(paths).Replace('/', Path.DirectorySeparatorChar);
private static string? TryGetRepoRoot()
{
var currentDir = new DirectoryInfo(Environment.CurrentDirectory);
while (currentDir.Parent is { } parentDir)
{
// search upwards for the .git directory. This should only exist at the repository root.
if (Directory.Exists(Path.Combine(currentDir.FullName, ".git")))
{
return currentDir.FullName;
}
currentDir = parentDir;
}
// on CI systems, there's no guarantee we'll be able to find the .git folder
return null;
}