fix: use partial document for VCS disconnect updates

This commit is contained in:
harsh mahajan committed 2026-06-24 19:05:13 +05:30
1 parent f5bb65f50e
commit 0d3038ffe9
2 files changed
+21 -19

No files matched your search

@@ -298,7 +298,7 @@ class Builds extends Action
try {
$github->initializeVariables($providerInstallationId, $privateKey, $githubAppId);
} catch (\Exception $e) {
if (\str_contains($e->getMessage(), 'Status: 404')
if ($e->getCode() === 404
&& $resource->getAttribute('installationId', '') === $installationId) {
$this->disconnectVcs($resource, $dbForProject, $dbForPlatform);
}
@@ -1569,15 +1569,16 @@ class Builds extends Action
if (!empty($repositoryId)) {
$dbForPlatform->deleteDocument('repositories', $repositoryId);
}
$dbForProject->updateDocument($resource->getCollection(), $resource->getId(), $resource
->setAttribute('installationId', '')
->setAttribute('installationInternalId', '')
->setAttribute('providerRepositoryId', '')
->setAttribute('providerBranch', '')
->setAttribute('providerSilentMode', false)
->setAttribute('providerRootDirectory', '')
->setAttribute('repositoryId', '')
->setAttribute('repositoryInternalId', ''));
$dbForProject->updateDocument($resource->getCollection(), $resource->getId(), new Document([
'installationId' => '',
'installationInternalId' => '',
'providerRepositoryId' => '',
'providerBranch' => '',
'providerSilentMode' => false,
'providerRootDirectory' => '',
'repositoryId' => '',
'repositoryInternalId' => '',
]));
}
private function updateLatestDeployment(Database $dbForProject, Document $resource): Document
@@ -135,15 +135,16 @@ class Create extends Action
$resources = $authorization->skip(fn () => $dbForProject->find($collection, $queries));
foreach ($resources as $resource) {
$authorization->skip(fn () => $dbForProject->updateDocument($collection, $resource->getId(), $resource
->setAttribute('installationId', '')
->setAttribute('installationInternalId', '')
->setAttribute('providerRepositoryId', '')
->setAttribute('providerBranch', '')
->setAttribute('providerSilentMode', false)
->setAttribute('providerRootDirectory', '')
->setAttribute('repositoryId', '')
->setAttribute('repositoryInternalId', '')));
$authorization->skip(fn () => $dbForProject->updateDocument($collection, $resource->getId(), new Document([
'installationId' => '',
'installationInternalId' => '',
'providerRepositoryId' => '',
'providerBranch' => '',
'providerSilentMode' => false,
'providerRootDirectory' => '',
'repositoryId' => '',
'repositoryInternalId' => '',
])));
}
$cursor = count($resources) === 1000 ? $resources[array_key_last($resources)] : null;