File tree Expand file tree Collapse file tree 4 files changed +11
-12
lines changed
McpServer/Action/Tools/Filesystem Expand file tree Collapse file tree 4 files changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,6 @@ public function executeString(Command $command): string
50
50
51
51
try {
52
52
$ process = new Process ($ commandParts , $ repositoryPath );
53
- trap ($ process );
54
53
$ process ->run ();
55
54
56
55
if (!$ process ->isSuccessful ()) {
@@ -144,6 +143,15 @@ public function isValidRepository(string $repository): bool
144
143
public function applyPatch (string $ filePath , string $ patchContent ): string
145
144
{
146
145
$ 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
+
147
155
$ file = $ rootPath ->join ($ filePath );
148
156
149
157
// Ensure the file exists
Original file line number Diff line number Diff line change @@ -64,16 +64,6 @@ public function __invoke(ServerRequestInterface $request): CallToolResult
64
64
}
65
65
66
66
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
77
67
$ result = $ this ->commandsExecutor ->applyPatch ($ path , $ patch );
78
68
79
69
return new CallToolResult ([
Original file line number Diff line number Diff line change 13
13
* @param GitSourceInterface[] $sources Array of Git source instances
14
14
*/
15
15
public function __construct (
16
+ private GitSourceInterface $ fallbackSource ,
16
17
#[LoggerPrefix(prefix: 'git-source-factory ' )]
17
18
private ?LoggerInterface $ logger = null ,
18
19
private array $ sources = [],
19
- private GitSourceInterface $ fallbackSource ,
20
20
) {}
21
21
22
22
public function create (string $ commitReference ): GitSourceInterface
Original file line number Diff line number Diff line change 20
20
21
21
final class GitDiffSourceBootloader extends Bootloader
22
22
{
23
+ #[\Override]
23
24
public function defineDependencies (): array
24
25
{
25
26
return [GitClientBootloader::class];
You can’t perform that action at this time.
0 commit comments