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
This commit is contained in:
parent
9b4abe753d
commit
1fe7df7e38
2 changed files with 27 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue