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(git): trim whitespace from repository, branch, and commit SHA fields

Andras Bacsai1fe7df7e3856
diff --git a/app/Livewire/Project/Application/Source.php b/app/Livewire/Project/Application/Source.php
index 29be68b6c8..ab2517f2bd 100644
--- a/app/Livewire/Project/Application/Source.php
+++ b/app/Livewire/Project/Application/Source.php
@@ -47,6 +47,21 @@ class Source extends Component
}
}
+ 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 @@ class Source extends Component
'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 9fffdfcdab..4f1796790b 100644
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@ -155,6 +155,15 @@ class Application extends BaseModel
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();
}