Skip to main content
Glama

CTX: Context as Code (CaC) tool

by context-hub
MIT License
235
  • Apple
  • Linux
GitSourceFactory.php1.85 kB
<?php declare(strict_types=1); namespace Butschster\ContextGenerator\Source\GitDiff\Fetcher; use Butschster\ContextGenerator\Application\Logger\LoggerPrefix; use Psr\Log\LoggerInterface; final readonly class GitSourceFactory { /** * @param GitSourceInterface[] $sources Array of Git source instances */ public function __construct( private GitSourceInterface $fallbackSource, #[LoggerPrefix(prefix: 'git-source-factory')] private ?LoggerInterface $logger = null, private array $sources = [], ) {} public function create(string $commitReference): GitSourceInterface { return $this->createForSingleReference($commitReference); } /** * Create a Git source for a single commit reference * * @param string $commitReference The commit reference * @return GitSourceInterface The appropriate Git source * @throws \InvalidArgumentException If no source supports the given reference */ private function createForSingleReference(string $commitReference): GitSourceInterface { $this->logger?->debug('Finding Git source for commit reference', [ 'commitReference' => $commitReference, ]); // Find the first source that supports this reference foreach ($this->sources as $source) { if ($source->supports($commitReference)) { $this->logger?->debug('Found supporting Git source', [ 'source' => $source::class, 'commitReference' => $commitReference, ]); return $source; } } $this->logger?->info('No specific Git source found, using fallback CommitGitSource', [ 'commitReference' => $commitReference, ]); return $this->fallbackSource; } }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/context-hub/generator'

If you have feedback or need assistance with the MCP directory API, please join our Discord server