Improve code robustness
@@ -24,13 +24,19 @@ $syncFromGit = function (string $orgName, string $repoName, string $sourceDir, s
$fullName = "{$orgName}/{$repoName}";
log("Sync {$fullName}...");
$url = null;
- for ($level = 2; $level < 5; $level++) {
+ for ($baseLevel = 1; $baseLevel < 10; $baseLevel++) {
+ $path = dirname(__DIR__, $baseLevel);
+ if (file_exists("{$path}/.git")) {
+ for ($level = $baseLevel + 1; $level < $baseLevel + 3; $level++) {
$path = dirname(__DIR__, $level) . '/' . $repoName;
if (file_exists("{$path}/.git")) {
$url = "file://{$path}";
break;
}
}
+ break;
+ }
+ }
if ($url === null) {
$url = "git@github.com:{$fullName}.git";
}
