mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
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.
This commit is contained in:
1 parent
8dd7549eeb
commit
2813d65fcd
3 files changed
+5
-12
No files matched your search
@@ -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']);
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user