Skip to content

Commit 2852328

Browse files
committed
cs fix
1 parent 5b6816f commit 2852328

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

src/Lib/Git/CommandsExecutor.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public function executeString(Command $command): string
5050

5151
try {
5252
$process = new Process($commandParts, $repositoryPath);
53-
trap($process);
5453
$process->run();
5554

5655
if (!$process->isSuccessful()) {
@@ -144,6 +143,15 @@ public function isValidRepository(string $repository): bool
144143
public function applyPatch(string $filePath, string $patchContent): string
145144
{
146145
$rootPath = $this->dirs->getRootPath();
146+
147+
if (!$this->isValidRepository((string) $rootPath)) {
148+
$this->logger?->error('Not a valid Git repository', [
149+
'repository' => (string) $rootPath,
150+
]);
151+
152+
throw new \InvalidArgumentException(\sprintf('"%s" is not a valid Git repository', $rootPath));
153+
}
154+
147155
$file = $rootPath->join($filePath);
148156

149157
// Ensure the file exists

src/McpServer/Action/Tools/Filesystem/FileApplyPatchAction.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,6 @@ public function __invoke(ServerRequestInterface $request): CallToolResult
6464
}
6565

6666
try {
67-
// Check if the directory is a git repository
68-
if (!$this->commandsExecutor->isGitRepository()) {
69-
return new CallToolResult([
70-
new TextContent(
71-
text: 'Error: The project directory is not a git repository',
72-
),
73-
], isError: true);
74-
}
75-
76-
// Apply the patch
7767
$result = $this->commandsExecutor->applyPatch($path, $patch);
7868

7969
return new CallToolResult([

src/Source/GitDiff/Fetcher/GitSourceFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
* @param GitSourceInterface[] $sources Array of Git source instances
1414
*/
1515
public function __construct(
16+
private GitSourceInterface $fallbackSource,
1617
#[LoggerPrefix(prefix: 'git-source-factory')]
1718
private ?LoggerInterface $logger = null,
1819
private array $sources = [],
19-
private GitSourceInterface $fallbackSource,
2020
) {}
2121

2222
public function create(string $commitReference): GitSourceInterface

src/Source/GitDiff/GitDiffSourceBootloader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
final class GitDiffSourceBootloader extends Bootloader
2222
{
23+
#[\Override]
2324
public function defineDependencies(): array
2425
{
2526
return [GitClientBootloader::class];

0 commit comments

Comments
 (0)