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,17 +1321,43 @@ 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();
$commands = collect([ if (version_compare($gitVersion, '2.35.1', '<')) {
"rm -rf /tmp/{$uuid}", $fileList = $fileList->map(function ($file) {
"mkdir -p /tmp/{$uuid}", $parts = explode('/', trim($file, '.'));
"cd /tmp/{$uuid}", $paths = collect();
$cloneCommand, $currentPath = '';
'git sparse-checkout init --cone', foreach ($parts as $part) {
"git sparse-checkout set {$fileList->implode(' ')}", $currentPath .= ($currentPath ? '/' : '').$part;
'git read-tree -mu HEAD', $paths->push($currentPath);
"cat .$workdir$composeFile", }
]);
return $paths;
})->flatten()->unique()->values();
$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",
]);
} 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) {