From 2813d65fcd5440d6d59eaa4bb59edecee22bb2be Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Wed, 15 Jul 2026 17:28:51 +0530 Subject: [PATCH] Drop the gitHub DI resource, call fromProvider('github') inline No special-cased resource for a single provider; both remaining call sites now resolve the adapter directly, matching the existing pattern in Builds.php and GitHub/Events/Create.php. Duplicate/Create.php's installation-based branch now resolves via fromInstallation() instead of hardcoding GitHub, since it duplicates deployments from any connected provider, not just GitHub. --- app/init/resources.php | 1 - .../Functions/Http/Deployments/Duplicate/Create.php | 12 ++++-------- .../Functions/Http/Deployments/Template/Create.php | 4 +--- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/app/init/resources.php b/app/init/resources.php index c08f823f9e..8957b4f8ff 100644 --- a/app/init/resources.php +++ b/app/init/resources.php @@ -379,7 +379,6 @@ $container->set('servers', function () { $container->set('promiseAdapter', fn ($register) => $register->get('promiseAdapter'), ['register']); $container->set('vcsFactory', fn (Cache $cache) => new VcsFactory($cache), ['cache']); -$container->set('gitHub', fn (VcsFactory $vcsFactory) => $vcsFactory->fromProvider('github'), ['vcsFactory']); $container->set('installationTokens', fn () => new InstallationTokens(), []); $container->set('repositoryWebhooks', fn (VcsFactory $vcsFactory) => new RepositoryWebhooks($vcsFactory), ['vcsFactory']); diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php index 44d6cdd68b..c80249d8a9 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php @@ -9,13 +9,13 @@ use Appwrite\SDK\AuthType; use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response; +use Appwrite\Vcs\Factory as VcsFactory; use Utopia\Database\Database; use Utopia\Database\Helpers\ID; use Utopia\Database\Validator\UID; use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; use Utopia\Storage\Device; -use Utopia\System\System; use Utopia\VCS\Adapter\Git\GitHub; class Create extends Action @@ -66,7 +66,7 @@ class Create extends Action ->inject('queueForEvents') ->inject('deployments') ->inject('deviceForFunctions') - ->inject('gitHub') + ->inject('vcsFactory') ->callback($this->action(...)); } @@ -80,7 +80,7 @@ class Create extends Action Event $queueForEvents, Backend $deployments, Device $deviceForFunctions, - GitHub $github, + VcsFactory $vcsFactory, ) { $function = $dbForProject->getDocument('functions', $functionId); @@ -144,11 +144,7 @@ class Create extends Action throw new Exception(Exception::INSTALLATION_NOT_FOUND); } - $github->initializeVariables( - $installation->getAttribute('providerInstallationId', ''), - System::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'), - System::getEnv('_APP_VCS_GITHUB_APP_ID'), - ); + $github = $vcsFactory->fromInstallation($installation); $ref = $deployment->getAttribute('providerCommitHash') ?: $deployment->getAttribute('providerBranch'); $deployment = $deployments->createFromUrl( diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Template/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Template/Create.php index 699425ce39..8ce0644678 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Template/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Template/Create.php @@ -81,7 +81,6 @@ class Create extends Base ->inject('publisherForBuilds') ->inject('vcsFactory') ->inject('deployments') - ->inject('gitHub') ->inject('authorization') ->inject('platform') ->callback($this->action(...)); @@ -104,7 +103,6 @@ class Create extends Base BuildPublisher $publisherForBuilds, VcsFactory $vcsFactory, Backend $deployments, - GitHub $github, Authorization $authorization, array $platform ) { @@ -170,7 +168,7 @@ class Create extends Base $ref = $reference; if ($type === GitHub::CLONE_TYPE_TAG && \str_contains($reference, '*')) { try { - $tags = $github->listTags($owner, $repository, $reference); + $tags = $vcsFactory->fromProvider('github')->listTags($owner, $repository, $reference); $ref = \end($tags) ?: $reference; } catch (\Throwable) { // Fall back to the raw reference; the build surfaces a bad ref.