From 1fe7df7e38567fc47061301a896e8018444452b1 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Tue, 30 Sep 2025 12:33:40 +0200 Subject: [PATCH] fix(git): trim whitespace from repository, branch, and commit SHA fields - Add automatic trimming in Application model's boot method for git_repository, git_branch, and git_commit_sha fields - Add real-time trimming in Source Livewire component via updated{Property} methods - Refresh component state after save to ensure UI displays trimmed values - Prevents deployment issues caused by accidental whitespace in git configuration --- app/Livewire/Project/Application/Source.php | 18 ++++++++++++++++++ app/Models/Application.php | 9 +++++++++ 2 files changed, 27 insertions(+) diff --git a/app/Livewire/Project/Application/Source.php b/app/Livewire/Project/Application/Source.php index 29be68b6c..ab2517f2b 100644 --- a/app/Livewire/Project/Application/Source.php +++ b/app/Livewire/Project/Application/Source.php @@ -47,6 +47,21 @@ public function mount() } } + public function updatedGitRepository() + { + $this->gitRepository = trim($this->gitRepository); + } + + public function updatedGitBranch() + { + $this->gitBranch = trim($this->gitBranch); + } + + public function updatedGitCommitSha() + { + $this->gitCommitSha = trim($this->gitCommitSha); + } + public function syncData(bool $toModel = false) { if ($toModel) { @@ -57,6 +72,9 @@ public function syncData(bool $toModel = false) 'git_commit_sha' => $this->gitCommitSha, 'private_key_id' => $this->privateKeyId, ]); + // Refresh to get the trimmed values from the model + $this->application->refresh(); + $this->syncData(false); } else { $this->gitRepository = $this->application->git_repository; $this->gitBranch = $this->application->git_branch; diff --git a/app/Models/Application.php b/app/Models/Application.php index 9fffdfcda..4f1796790 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -155,6 +155,15 @@ protected static function booted() if ($application->isDirty('publish_directory')) { $payload['publish_directory'] = str($application->publish_directory)->trim(); } + if ($application->isDirty('git_repository')) { + $payload['git_repository'] = str($application->git_repository)->trim(); + } + if ($application->isDirty('git_branch')) { + $payload['git_branch'] = str($application->git_branch)->trim(); + } + if ($application->isDirty('git_commit_sha')) { + $payload['git_commit_sha'] = str($application->git_commit_sha)->trim(); + } if ($application->isDirty('status')) { $payload['last_online_at'] = now(); }