TQ\Svn\Repository\Repository::findRepositoryRoot PHP Method

findRepositoryRoot() public static method

Tries to find the root directory for a given repository path
public static findRepositoryRoot ( Binary $svn, string $path ) : string | null
$svn TQ\Svn\Cli\Binary The SVN binary
$path string The file system path
return string | null NULL if the root cannot be found, the root path otherwise
    public static function findRepositoryRoot(Binary $svn, $path)
    {
        $hasSvnDir = function ($path) {
            $svnDir = $path . '/' . '.svn';
            return file_exists($svnDir) && is_dir($svnDir);
        };
        $pathWithSvnDir = FileSystem::bubble($path, $hasSvnDir);
        $root = $pathWithSvnDir;
        $parentDir = dirname($pathWithSvnDir);
        while ($hasSvnDir($parentDir) && strlen($root) > 1) {
            $root = dirname($root);
            $parentDir = dirname($parentDir);
        }
        return $root;
    }