fix: migrate .mokostandards from .github/ to .gitea/ on Gitea
migrateMokoStandards() now checks both root and .github/.mokostandards as sources, migrating to .gitea/.mokostandards when running on Gitea. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -706,20 +706,35 @@ HCL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate .mokostandards from repo root to .github/.mokostandards.
|
||||
* Deletes the root file after copying to .github/.
|
||||
* Migrate .mokostandards to the platform metadata dir (.gitea/ or .github/).
|
||||
* Handles migration from root and from .github/ → .gitea/ on Gitea.
|
||||
*/
|
||||
private function migrateMokoStandards(string $org, string $repo, string $branchName, array &$summary): void
|
||||
{
|
||||
$metaDir = $this->adapter->getMetadataDir();
|
||||
$targetPath = "{$metaDir}/.mokostandards";
|
||||
|
||||
// Check if .mokostandards exists in root
|
||||
try {
|
||||
$rootFile = $this->adapter->getFileContents($org, $repo, '.mokostandards', $branchName);
|
||||
} catch (Exception $e) {
|
||||
$this->adapter->getApiClient()->resetCircuitBreaker();
|
||||
return; // Doesn't exist in root — nothing to migrate
|
||||
// Sources to check, in priority order
|
||||
$sources = ['.mokostandards'];
|
||||
// On Gitea, also migrate from .github/.mokostandards → .gitea/.mokostandards
|
||||
if ($metaDir === '.gitea') {
|
||||
$sources[] = '.github/.mokostandards';
|
||||
}
|
||||
|
||||
$rootFile = null;
|
||||
$sourcePath = null;
|
||||
foreach ($sources as $path) {
|
||||
try {
|
||||
$rootFile = $this->adapter->getFileContents($org, $repo, $path, $branchName);
|
||||
$sourcePath = $path;
|
||||
break;
|
||||
} catch (Exception $e) {
|
||||
$this->adapter->getApiClient()->resetCircuitBreaker();
|
||||
}
|
||||
}
|
||||
|
||||
if ($rootFile === null) {
|
||||
return; // Nothing to migrate
|
||||
}
|
||||
|
||||
// Check if already exists in metadata dir
|
||||
@@ -750,15 +765,15 @@ HCL;
|
||||
}
|
||||
}
|
||||
|
||||
// Delete from root
|
||||
if (!empty($rootSha)) {
|
||||
// Delete old source file
|
||||
if (!empty($rootSha) && $sourcePath !== $targetPath) {
|
||||
try {
|
||||
$this->adapter->deleteFile(
|
||||
$org, $repo, '.mokostandards', $rootSha,
|
||||
"chore: remove .mokostandards from root (moved to {$metaDir}/)",
|
||||
$org, $repo, $sourcePath, $rootSha,
|
||||
"chore: remove {$sourcePath} (moved to {$targetPath})",
|
||||
$branchName
|
||||
);
|
||||
$this->logger->logInfo("Deleted root .mokostandards");
|
||||
$this->logger->logInfo("Deleted {$sourcePath}");
|
||||
} catch (Exception $e) {
|
||||
$this->adapter->getApiClient()->resetCircuitBreaker();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user