public function getProjectRoot()
{
// Backwards compatibility - if in an old-style project root, change
// directory to the repository.
if (is_dir('repository') && file_exists($this->config->get('local.project_config_legacy'))) {
$cwd = getcwd();
chdir('repository');
}
// The project root is a Git repository, which contains a project
// configuration file, and/or contains a Git remote with the appropriate
// domain.
$dir = $this->findTopDirectoryContaining('.git', function ($dir) {
$config = $this->getProjectConfig($dir);
return !empty($config);
});
if (isset($cwd)) {
chdir($cwd);
}
return $dir;
}