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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix: handle / in preselecting branches
Andras Bacsai4c031a7c0588
diff --git a/app/Livewire/Project/New/PublicGitRepository.php b/app/Livewire/Project/New/PublicGitRepository.phpindex 867d398df8..bf6324c64d 100644--- a/app/Livewire/Project/New/PublicGitRepository.php+++ b/app/Livewire/Project/New/PublicGitRepository.php@@ -25,11 +25,11 @@ class PublicGitRepository extends Componentpublic $query;- public bool $branch_found = false;+ public bool $branchFound = false;- public string $selected_branch = 'main';+ public string $selectedBranch = 'main';- public bool $is_static = false;+ public bool $isStatic = false;public ?string $publish_directory = null;@@ -62,7 +62,7 @@ class PublicGitRepository extends Componentprotected $rules = ['repository_url' => 'required|url','port' => 'required|numeric',- 'is_static' => 'required|boolean',+ 'isStatic' => 'required|boolean','publish_directory' => 'nullable|string','build_pack' => 'required|string','base_directory' => 'nullable|string',@@ -72,7 +72,7 @@ class PublicGitRepository extends Componentprotected $validationAttributes = ['repository_url' => 'repository','port' => 'port',- 'is_static' => 'static',+ 'isStatic' => 'static','publish_directory' => 'publish directory','build_pack' => 'build pack','base_directory' => 'base directory',@@ -106,17 +106,17 @@ class PublicGitRepository extends Component$this->port = 3000;} elseif ($this->build_pack === 'static') {$this->show_is_static = false;- $this->is_static = false;+ $this->isStatic = false;$this->port = 80;} else {$this->show_is_static = false;- $this->is_static = false;+ $this->isStatic = false;}}public function instantSave(){- if ($this->is_static) {+ if ($this->isStatic) {$this->port = 80;$this->publish_directory = '/dist';} else {@@ -126,12 +126,7 @@ class PublicGitRepository extends Component$this->dispatch('success', 'Application settings updated!');}- public function load_any_git()- {- $this->branch_found = true;- }-- public function load_branch()+ public function loadBranch(){try {if (str($this->repository_url)->startsWith('git@')) {@@ -155,15 +150,15 @@ class PublicGitRepository extends Componentreturn handleError($e, $this);}try {- $this->branch_found = false;- $this->get_git_source();- $this->get_branch();- $this->selected_branch = $this->git_branch;+ $this->branchFound = false;+ $this->getGitSource();+ $this->getBranch();+ $this->selectedBranch = $this->git_branch;} catch (\Throwable $e) {- if (! $this->branch_found && $this->git_branch == 'main') {+ if (! $this->branchFound && $this->git_branch == 'main') {try {$this->git_branch = 'master';- $this->get_branch();+ $this->getBranch();} catch (\Throwable $e) {return handleError($e, $this);}@@ -173,13 +168,16 @@ class PublicGitRepository extends Component}}- private function get_git_source()+ private function getGitSource(){$this->repository_url_parsed = Url::fromString($this->repository_url);$this->git_host = $this->repository_url_parsed->getHost();$this->git_repository = $this->repository_url_parsed->getSegment(1).'/'.$this->repository_url_parsed->getSegment(2);- $this->git_branch = $this->repository_url_parsed->getSegment(4) ?? 'main';-+ if ($this->repository_url_parsed->getSegment(3) === 'tree') {+ $this->git_branch = str($this->repository_url_parsed->getPath())->after('tree/')->value();+ } else {+ $this->git_branch = 'main';+ }if ($this->git_host == 'github.com') {$this->git_source = GithubApp::where('name', 'Public GitHub')->first();@@ -189,17 +187,17 @@ class PublicGitRepository extends Component$this->git_source = 'other';}- private function get_branch()+ private function getBranch(){if ($this->git_source === 'other') {- $this->branch_found = true;+ $this->branchFound = true;return;}if ($this->git_source->getMorphClass() === 'App\Models\GithubApp') {['rate_limit_remaining' => $this->rate_limit_remaining, 'rate_limit_reset' => $this->rate_limit_reset] = githubApi(source: $this->git_source, endpoint: "/repos/{$this->git_repository}/branches/{$this->git_branch}");$this->rate_limit_reset = Carbon::parse((int) $this->rate_limit_reset)->format('Y-M-d H:i:s');- $this->branch_found = true;+ $this->branchFound = true;}}@@ -287,7 +285,7 @@ class PublicGitRepository extends Component}$application = Application::create($application_init);- $application->settings->is_static = $this->is_static;+ $application->settings->is_static = $this->isStatic;$application->settings->save();$fqdn = generateFqdn($destination->server, $application->uuid);diff --git a/resources/views/livewire/project/new/public-git-repository.blade.php b/resources/views/livewire/project/new/public-git-repository.blade.phpindex b9803d24fd..17ef0a1889 100644--- a/resources/views/livewire/project/new/public-git-repository.blade.php+++ b/resources/views/livewire/project/new/public-git-repository.blade.php@@ -1,7 +1,7 @@<div><h1>Create a new Application</h1><div class="pb-4">Deploy any public Git repositories.</div>- <form class="flex flex-col gap-2" wire:submit='load_branch'>+ <form class="flex flex-col gap-2" wire:submit='loadBranch'><div class="flex flex-col gap-2"><div class="flex flex-col gap-2"><div class="flex items-end gap-2">@@ -11,7 +11,7 @@Check repository</x-forms.button></div>- @if (!$branch_found)+ @if (!$branchFound)<div class="px-2 pt-4"><div>For example application deployments, checkout <a class="underline dark:text-white"@@ -19,7 +19,7 @@Examples</a>.</div>@endif- @if ($branch_found)+ @if ($branchFound)@if ($rate_limit_remaining && $rate_limit_reset)<div class="flex gap-2 py-2"><div>Rate Limit</div>@@ -42,7 +42,7 @@<option value="dockerfile">Dockerfile</option><option value="dockercompose">Docker Compose</option></x-forms.select>- @if ($is_static)+ @if ($isStatic)<x-forms.input id="publish_directory" label="Publish Directory"helper="If there is a build process involved (like Svelte, React, Next, etc..), please specify the output directory for the build assets." />@endif@@ -57,10 +57,10 @@class='dark:text-warning'>{{ Str::start($base_directory . $docker_compose_location, '/') }}</span>@endif@if ($show_is_static)- <x-forms.input type="number" id="port" label="Port" :readonly="$is_static || $build_pack === 'static'"+ <x-forms.input type="number" id="port" label="Port" :readonly="$isStatic || $build_pack === 'static'"helper="The port your application listens on." /><div class="w-52">- <x-forms.checkbox instantSave id="is_static" label="Is it a static site?"+ <x-forms.checkbox instantSave id="isStatic" label="Is it a static site?"helper="If your application is a static site or the final build assets should be served as a static site, enable this." /></div>@endif