rename vcsRepos to vcsRepositories
This commit is contained in:
parent
e6d1a3424f
commit
22f638e6aa
4 changed files with 22 additions and 22 deletions
|
@ -2352,10 +2352,10 @@ $collections = [
|
|||
],
|
||||
],
|
||||
|
||||
'vcsRepos' => [
|
||||
'vcsRepositories' => [
|
||||
'$collection' => ID::custom(Database::METADATA),
|
||||
'$id' => ID::custom('vcsRepos'),
|
||||
'name' => 'vcsRepos',
|
||||
'$id' => ID::custom('vcsRepositories'),
|
||||
'name' => 'vcsRepositories',
|
||||
'attributes' => [
|
||||
[
|
||||
'$id' => ID::custom('vcsInstallationId'),
|
||||
|
|
|
@ -187,7 +187,7 @@ App::post('/v1/functions')
|
|||
|
||||
// Git connect logic
|
||||
if (!empty($vcsRepositoryId)) {
|
||||
$vcsRepoDoc = $dbForConsole->createDocument('vcsRepos', new Document([
|
||||
$vcsRepoDoc = $dbForConsole->createDocument('vcsRepositories', new Document([
|
||||
'$id' => ID::unique(),
|
||||
'$permissions' => [
|
||||
Permission::read(Role::any()),
|
||||
|
@ -684,7 +684,7 @@ App::put('/v1/functions/:functionId')
|
|||
|
||||
// Git disconnect logic
|
||||
if ($isConnected && empty($vcsRepositoryId)) {
|
||||
$repoDocs = $dbForConsole->find('vcsRepos', [
|
||||
$repoDocs = $dbForConsole->find('vcsRepositories', [
|
||||
Query::equal('projectInternalId', [$project->getInternalId()]),
|
||||
Query::equal('resourceInternalId', [$function->getInternalId()]),
|
||||
Query::equal('resourceType', ['function']),
|
||||
|
@ -692,7 +692,7 @@ App::put('/v1/functions/:functionId')
|
|||
]);
|
||||
|
||||
foreach ($repoDocs as $repoDoc) {
|
||||
$dbForConsole->deleteDocument('vcsRepos', $repoDoc->getId());
|
||||
$dbForConsole->deleteDocument('vcsRepositories', $repoDoc->getId());
|
||||
}
|
||||
|
||||
$vcsRepositoryId = '';
|
||||
|
@ -706,7 +706,7 @@ App::put('/v1/functions/:functionId')
|
|||
|
||||
// Git connect logic
|
||||
if (!$isConnected && !empty($vcsRepositoryId)) {
|
||||
$vcsRepoDoc = $dbForConsole->createDocument('vcsRepos', new Document([
|
||||
$vcsRepoDoc = $dbForConsole->createDocument('vcsRepositories', new Document([
|
||||
'$id' => ID::unique(),
|
||||
'$permissions' => [
|
||||
Permission::read(Role::any()),
|
||||
|
|
|
@ -728,12 +728,12 @@ App::post('/v1/vcs/github/events')
|
|||
$github->initialiseVariables($installationId, $privateKey, $githubAppId);
|
||||
|
||||
//find functionId from functions table
|
||||
$vcsRepos = $dbForConsole->find('vcsRepos', [
|
||||
$vcsRepositories = $dbForConsole->find('vcsRepositories', [
|
||||
Query::equal('repositoryId', [$repositoryId]),
|
||||
Query::limit(100),
|
||||
]);
|
||||
|
||||
$createGitDeployments($github, $installationId, $vcsRepos, $branchName, $vcsCommitHash, '', false, $dbForConsole, $getProjectDB, $request);
|
||||
$createGitDeployments($github, $installationId, $vcsRepositories, $branchName, $vcsCommitHash, '', false, $dbForConsole, $getProjectDB, $request);
|
||||
} elseif ($event == $github::EVENT_INSTALLATION) {
|
||||
if ($parsedPayload["action"] == "deleted") {
|
||||
// TODO: Use worker for this job instead (update function as well)
|
||||
|
@ -745,13 +745,13 @@ App::post('/v1/vcs/github/events')
|
|||
]);
|
||||
|
||||
foreach ($vcsInstallations as $installation) {
|
||||
$vcsRepos = $dbForConsole->find('vcsRepos', [
|
||||
$vcsRepositories = $dbForConsole->find('vcsRepositories', [
|
||||
Query::equal('vcsInstallationInternalId', [$installation->getInternalId()]),
|
||||
Query::limit(1000)
|
||||
]);
|
||||
|
||||
foreach ($vcsRepos as $repo) {
|
||||
$dbForConsole->deleteDocument('vcsRepos', $repo->getId());
|
||||
foreach ($vcsRepositories as $vcsRepository) {
|
||||
$dbForConsole->deleteDocument('vcsRepositories', $vcsRepository->getId());
|
||||
}
|
||||
|
||||
$dbForConsole->deleteDocument('vcsInstallations', $installation->getId());
|
||||
|
@ -773,12 +773,12 @@ App::post('/v1/vcs/github/events')
|
|||
|
||||
$github->initialiseVariables($installationId, $privateKey, $githubAppId);
|
||||
|
||||
$vcsRepos = $dbForConsole->find('vcsRepos', [
|
||||
$vcsRepositories = $dbForConsole->find('vcsRepositories', [
|
||||
Query::equal('repositoryId', [$repositoryId]),
|
||||
Query::orderDesc('$createdAt')
|
||||
]);
|
||||
|
||||
$createGitDeployments($github, $installationId, $vcsRepos, $branchName, $vcsCommitHash, $pullRequestNumber, $external, $dbForConsole, $getProjectDB, $request);
|
||||
$createGitDeployments($github, $installationId, $vcsRepositories, $branchName, $vcsCommitHash, $pullRequestNumber, $external, $dbForConsole, $getProjectDB, $request);
|
||||
} elseif ($parsedPayload["action"] == "closed") {
|
||||
// Allowed external contributions cleanup
|
||||
|
||||
|
@ -787,19 +787,19 @@ App::post('/v1/vcs/github/events')
|
|||
$external = $parsedPayload["external"] ?? true;
|
||||
|
||||
if ($external) {
|
||||
$vcsRepos = $dbForConsole->find('vcsRepos', [
|
||||
$vcsRepositories = $dbForConsole->find('vcsRepositories', [
|
||||
Query::equal('repositoryId', [$repositoryId]),
|
||||
Query::orderDesc('$createdAt')
|
||||
]);
|
||||
|
||||
foreach ($vcsRepos as $vcsRepository) {
|
||||
foreach ($vcsRepositories as $vcsRepository) {
|
||||
$pullRequests = $vcsRepository->getAttribute('pullRequests', []);
|
||||
|
||||
if (\in_array($pullRequestNumber, $pullRequests)) {
|
||||
$pullRequests = \array_diff($pullRequests, [$pullRequestNumber]);
|
||||
$vcsRepository = $vcsRepository->setAttribute('pullRequests', $pullRequests);
|
||||
|
||||
$vcsRepository = Authorization::skip(fn () => $dbForConsole->updateDocument('vcsRepos', $vcsRepository->getId(), $vcsRepository));
|
||||
$vcsRepository = Authorization::skip(fn () => $dbForConsole->updateDocument('vcsRepositories', $vcsRepository->getId(), $vcsRepository));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -955,7 +955,7 @@ App::patch('/v1/vcs/github/installations/:installationId/vcsRepositories/:vcsRep
|
|||
throw new Exception(Exception::INSTALLATION_NOT_FOUND);
|
||||
}
|
||||
|
||||
$vcsRepository = $dbForConsole->getDocument('vcsRepos', $vcsRepositoryId, [
|
||||
$vcsRepository = $dbForConsole->getDocument('vcsRepositories', $vcsRepositoryId, [
|
||||
Query::equal('projectInternalId', [$project->getInternalId()])
|
||||
]);
|
||||
|
||||
|
@ -972,14 +972,14 @@ App::patch('/v1/vcs/github/installations/:installationId/vcsRepositories/:vcsRep
|
|||
|
||||
// TODO: Delete from array when PR is closed
|
||||
|
||||
$vcsRepository = $dbForConsole->updateDocument('vcsRepos', $vcsRepository->getId(), $vcsRepository);
|
||||
$vcsRepository = $dbForConsole->updateDocument('vcsRepositories', $vcsRepository->getId(), $vcsRepository);
|
||||
|
||||
$privateKey = App::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY');
|
||||
$githubAppId = App::getEnv('_APP_VCS_GITHUB_APP_ID');
|
||||
$installationId = $installation->getAttribute('installationId');
|
||||
$github->initialiseVariables($installationId, $privateKey, $githubAppId);
|
||||
|
||||
$vcsRepos = [$vcsRepository];
|
||||
$vcsRepositories = [$vcsRepository];
|
||||
$repositoryId = $vcsRepository->getAttribute('repositoryId');
|
||||
|
||||
$owner = $github->getOwnerName($installationId);
|
||||
|
@ -989,7 +989,7 @@ App::patch('/v1/vcs/github/installations/:installationId/vcsRepositories/:vcsRep
|
|||
$branchName = \explode(':', $pullRequestResponse['head']['label'])[1] ?? '';
|
||||
$vcsCommitHash = $pullRequestResponse['head']['sha'] ?? '';
|
||||
|
||||
$createGitDeployments($github, $installationId, $vcsRepos, $branchName, $vcsCommitHash, $pullRequest, true, $dbForConsole, $getProjectDB, $request);
|
||||
$createGitDeployments($github, $installationId, $vcsRepositories, $branchName, $vcsCommitHash, $pullRequest, true, $dbForConsole, $getProjectDB, $request);
|
||||
|
||||
$response->noContent();
|
||||
});
|
||||
|
|
|
@ -752,7 +752,7 @@ class DeletesV1 extends Worker
|
|||
$this->listByGroup('functions', [
|
||||
Query::equal('vcsInstallationInternalId', [$document->getInternalId()])
|
||||
], $dbForProject, function ($function) use ($dbForProject, $dbForConsole) {
|
||||
$dbForConsole->deleteDocument('vcsRepos', $function->getAttribute('vcsRepositoryId'));
|
||||
$dbForConsole->deleteDocument('vcsRepositories', $function->getAttribute('vcsRepositoryId'));
|
||||
|
||||
$function = $function
|
||||
->setAttribute('vcsInstallationId', '')
|
||||
|
|
Loading…
Reference in a new issue