Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: old git versions does not have --cone implemented properly

Andras Bacsaieeb8d97cfd18
diff --git a/app/Models/Application.php b/app/Models/Application.php
index a68c1d54a6..d1efd3f337 100644
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@ -1321,17 +1321,43 @@ class Application extends BaseModel
if (! $gitRemoteStatus['is_accessible']) {
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);
+ }
- $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",
- ]);
+ 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 {
$composeFileContent = instant_remote_process($commands, $this->destination->server);
} catch (\Exception $e) {