Skip to content

Commit 1c3bd76

Browse files
authored
Merge pull request #176 from context-hub/hotfix/168
feat: refactor file handling to use FSPath for temporary file creation
2 parents 52e2714 + 0015fb8 commit 1c3bd76

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

src/Console/MCPServerCommand.php

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public function __invoke(Container $container, DirectoriesInterface $dirs, Appli
109109
bindings: new Scope(
110110
name: AppScope::Mcp,
111111
bindings: [
112+
DirectoriesInterface::class => $dirs,
112113
ProjectServiceInterface::class => $projectServiceFactory->create(),
113114
HasPrefixLoggerInterface::class => $logger,
114115
ConfigLoaderInterface::class => $loader,

src/Source/GitDiff/Fetcher/Source/AbstractGitSource.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Butschster\ContextGenerator\Source\GitDiff\Fetcher\Source;
66

7+
use Butschster\ContextGenerator\Application\FSPath;
78
use Butschster\ContextGenerator\Lib\Git\Command;
89
use Butschster\ContextGenerator\Lib\Git\CommandsExecutorInterface;
910
use Butschster\ContextGenerator\Lib\Git\Exception\GitCommandException;
@@ -42,14 +43,14 @@ public function createFileInfos(string $repository, string $commitReference, str
4243
}
4344

4445
// Create the temporary file
45-
$tempFile = $tempDir . '/' . $file;
46-
$tempDirname = \dirname($tempFile);
46+
$tempFile = FSPath::create($tempDir)->join($file);
47+
$tempDirname = (string) $tempFile->parent();
4748

4849
$this->files->ensureDirectory($tempDirname, 0777);
49-
$this->files->write($tempFile, $diff);
50+
$this->files->write((string) $tempFile, $diff);
5051

5152
// Create a file info object with additional metadata
52-
$fileInfos[] = new class($tempFile, $file, $diff) extends SplFileInfo {
53+
$fileInfos[] = new class((string) $tempFile, $file, $diff) extends SplFileInfo {
5354
private readonly string $originalPath;
5455

5556
public function __construct(

src/Source/Tree/TreeSourceBootloader.php

-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
namespace Butschster\ContextGenerator\Source\Tree;
66

77
use Butschster\ContextGenerator\Application\Bootloader\SourceFetcherBootloader;
8-
use Butschster\ContextGenerator\Application\Logger\HasPrefixLoggerInterface;
98
use Butschster\ContextGenerator\DirectoriesInterface;
10-
use Butschster\ContextGenerator\Lib\Content\ContentBuilderFactory;
119
use Butschster\ContextGenerator\Source\Registry\SourceRegistryInterface;
1210
use Spiral\Boot\Bootloader\Bootloader;
1311
use Spiral\Core\FactoryInterface;
@@ -21,8 +19,6 @@ public function defineSingletons(): array
2119
TreeSourceFetcher::class => static fn(
2220
FactoryInterface $factory,
2321
DirectoriesInterface $dirs,
24-
ContentBuilderFactory $builderFactory,
25-
HasPrefixLoggerInterface $logger,
2622
): TreeSourceFetcher => $factory->make(TreeSourceFetcher::class, [
2723
'basePath' => (string) $dirs->getRootPath(),
2824
]),

src/Source/Tree/TreeSourceFetcher.php

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public function fetch(SourceInterface $source, ModifiersApplierInterface $modifi
4949
$this->logger?->info('Fetching tree source content', [
5050
'description' => $source->getDescription(),
5151
'basePath' => $this->basePath,
52+
'sourcePaths' => $source->sourcePaths,
5253
'renderFormat' => $source->renderFormat,
5354
'hasModifiers' => !empty($source->modifiers),
5455
]);

0 commit comments

Comments
 (0)