vito/app/Actions/Site/UpdateBranch.php
Dimitar Yanakiev e52903c649
fix: ensure newly created branches are available for switching (#511)
Fixed an issue where the "Change Branch" button didn't work when switching to a newly created remote branch after initially cloning the repository. Added `git fetch origin` to update branch references before switching.
2025-02-28 19:38:38 +01:00

34 lines
646 B
PHP
Executable File

<?php
namespace App\Actions\Site;
use App\Exceptions\SSHError;
use App\Models\Site;
use App\SSH\Git\Git;
use Illuminate\Validation\ValidationException;
class UpdateBranch
{
/**
* @throws ValidationException
* @throws SSHError
*/
public function update(Site $site, array $input): void
{
$site->branch = $input['branch'];
app(Git::class)->fetchOrigin($site);
app(Git::class)->checkout($site);
$site->save();
}
/**
* @throws ValidationException
*/
public static function rules(): array
{
return [
'branch' => 'required',
];
}
}