Merge branch 'next' into feat/disable-default-redirect

This commit is contained in:
Andras Bacsai
2024-12-06 11:36:11 +01:00

View File

@@ -1321,7 +1321,21 @@ class Application extends BaseModel
if (! $gitRemoteStatus['is_accessible']) { if (! $gitRemoteStatus['is_accessible']) {
throw new \RuntimeException("Failed to read Git source:\n\n{$gitRemoteStatus['error']}"); throw new \RuntimeException("Failed to read Git source:\n\n{$gitRemoteStatus['error']}");
} }
$getGitVersion = instant_remote_process(['git --version'], $this->destination->server, false);
$gitVersion = str($getGitVersion)->explode(' ')->last();
if (version_compare($gitVersion, '2.35.1', '<')) {
$fileList = $fileList->map(function ($file) {
$parts = explode('/', trim($file, '.'));
$paths = collect();
$currentPath = '';
foreach ($parts as $part) {
$currentPath .= ($currentPath ? '/' : '').$part;
$paths->push($currentPath);
}
return $paths;
})->flatten()->unique()->values();
$commands = collect([ $commands = collect([
"rm -rf /tmp/{$uuid}", "rm -rf /tmp/{$uuid}",
"mkdir -p /tmp/{$uuid}", "mkdir -p /tmp/{$uuid}",
@@ -1332,6 +1346,18 @@ class Application extends BaseModel
'git read-tree -mu HEAD', 'git read-tree -mu HEAD',
"cat .$workdir$composeFile", "cat .$workdir$composeFile",
]); ]);
} else {
$commands = collect([
"rm -rf /tmp/{$uuid}",
"mkdir -p /tmp/{$uuid}",
"cd /tmp/{$uuid}",
$cloneCommand,
'git sparse-checkout init --cone',
"git sparse-checkout set {$fileList->implode(' ')}",
'git read-tree -mu HEAD',
"cat .$workdir$composeFile",
]);
}
try { try {
$composeFileContent = instant_remote_process($commands, $this->destination->server); $composeFileContent = instant_remote_process($commands, $this->destination->server);
} catch (\Exception $e) { } catch (\Exception $e) {